SUM not working as expected in my table


Hello everybody!

I'm very new to Jaspersoft Studio and i'm facing a problem to sum values in my table. I will try to be as clear as possible.

I have an XML dataset construct like this (i've just put datas that are relevant for my question, it's not the complete XML)


So i make a table of distribution by age group like this

Male female
60 - 74 years

75 - 84 years

85 - 96 years

96 years and more

I have no problem to construct the table and (i think) no problem for the expression to create my variables. I use these variables to fill the table :

IF(INTEGER_VALUE($F{AGE_1} )>=85 && INTEGER_VALUE($F{AGE_1} )<=95 && $F{SEXE_1}.equals("M"),1,0)

If my age is between these values and depending the sex, i want 1 or 0. That's my expression and it's working well if i don't want to sum the result. I've 6 people (<RESIDENT>) in my XML and when i preview my table (which is in the detail area to see every change for every people when i preview). I put ascreenshot to let you see that is working this way.

We see here that the first page of the report is OK. We found a man (the "M" in orange) which is 72 years old (in red) so it put a 1 on the good cell. And all the 5 others persons in the 5 other pages of the report are OK. I always have a 1 in the good cell.

But now i want to sum all these 1 and 0 to have just one table with the sum. And that is where i have problem. I try to modify the way it's calculate so in my variable properties, i have change "nothing" to "sum" like you can see in the screen below.

But now i don't understand but i don't have the sum i need. Worst, it shows me the same even if i have only ONE person in my XML)

So we have one man of 65 years old. The value is in the good cell but why i have a 2???? It's the only person in my XML so how can i have 2 ??? Normally i should have 1 and if i have 1 other man of 60-74 years old it should be 2, and 3 if have another one , etc......

Maybe i've missed a thing to calculate this....

Hope someone can help me :)

Thanks in advance for your future answers.

siick's picture
Joined: Jul 3 2017 - 8:35am
Last seen: 3 years 4 months ago

Ok, i have found another way with a sub report in each cell with 3 parameters in my datase t: max_age, min_age and sex.

I had that filter expression


and i change the parameter for each cell to have the right data.

Anyway, i'm not sure it's a good way to have my result...

So if someone can tell me more, i will be glad

siick - 3 years 7 months ago

0 Answers:

No answers yet