# use sum of values in detail band

Hi,

I've a question which ahs been discussed here several times, but it seems that all the solutions are'nt working for me.

Following problem: In my detail-band I show a field named \$F{customerCount}. In the summary section I sum up this field and show the sum: \$V{sumCustomerCount}. That is working fine.

But additionally to the customerCount I want to show the percentage value of this customerCount from sum of customerCount. Therefor I added a new variable:

new BigDecimal(\$F{customerCount}.doubleValue() / \$V{sumCustomerCount}.doubleValue())

But this isn't working somehow. It seems, that the value for the sum isn't calculated yet.

Does anybody knows what to do???

Thanks,
Sebastian
158
Joined: Sep 25 2007 - 9:13pm
Last seen: 16 years 1 week ago

You can do that with evalutionType="Auto". Check out the "jasper" sample from the JR project distribution for a running example.

HTH,
Lucian
87435
Joined: Jul 17 2006 - 1:10am
Last seen: 1 day 6 hours ago
Hi Lucian,

thanks for your answer, but this seems not to be working for me. If I directly place the sum field in my detail band and set the evaluation type to auto everything is fine. In each detail band I have the same value for sum. But I try to use the field in another varible to calculate a percentage value. In this case the sum only contains the sum of all values printed until now.

For example:

Count | Sum should be | % should be | % is
1 | 9 | 1/9 = 11% | 1/1 = 100%
3 | 9 | 3/9 = 33% | 3/4 = 75%
5 | 9 | 5/9 = 56% | 5/9 = 56%

I tried a lot with changing evaluation type for all fields but it isn't working...

Any ideas???
Post edited by: BatiB80, at: 2007/11/27 07:45
158
Joined: Sep 25 2007 - 9:13pm
Last seen: 16 years 1 week ago
158
Joined: Sep 25 2007 - 9:13pm
Last seen: 16 years 1 week ago
and the second one... [file name=sample2.pdf size=1510]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/sam...
158
Joined: Sep 25 2007 - 9:13pm
Last seen: 16 years 1 week ago
BatiB80 wrote:
 thanks for your answer, but this seems not to be working for me. If I directly place the sum field in my detail band and set the evaluation type to auto everything is fine. In each detail band I have the same value for sum. But I try to use the field in another varible to calculate a percentage value. In this case the sum only contains the sum of all values printed until now.

evaluationTime="Auto" only works for text fields, so if you need to compute a percentage you'll have to do it in the text field itself (like the "jasper" sample does).

Regards,
Lucian
87435
Joined: Jul 17 2006 - 1:10am
Last seen: 1 day 6 hours ago
OK, it's working now!!!

Many thanks! :)
158
Joined: Sep 25 2007 - 9:13pm
Last seen: 16 years 1 week ago

Cannot find -> "Check out the "jasper" sample from the JR project distribution for a running example."

Where do I find that example?

421
Joined: Oct 18 2013 - 6:57am
Last seen: 1 year 5 months ago
randomness