Jump to content
We've recently updated our Privacy Statement, available here ×

SUM not working as expected in my table


siick

Recommended Posts

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)

<RAPPORT>    <HEADER>[.....]    </HEADER>    <DONNEES>        <RESIDENT>            <ID>1</ID>            <AGE>67</AGE>            <SEXE>M</SEXE>        </RESIDENT>        <RESIDENT>            <ID>1</ID>            <AGE>77</AGE>            <SEXE>F</SEXE>        </RESIDENT>        <RESIDENT>            <ID>1</ID>            <AGE>68</AGE>            <SEXE>M</SEXE>        </RESIDENT>        <RESIDENT>            <ID>1</ID>            <AGE>78</AGE>            <SEXE>F</SEXE>        </RESIDENT>[........]    </DONNEES></RAPPORT>[/code]

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

 Malefemale
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)[/code]

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.

http://pix.toile-libre.org/upload/original/1503664987.png

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.

http://pix.toile-libre.org/upload/original/1503665425.png

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)

http://pix.toile-libre.org/upload/original/1503665764.png

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.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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(INTEGER_VALUE($F{AGE_1})>=$P{age_min},INTEGER_VALUE($F{AGE_1})<=$P{age_max},$F{SEXE_1}.equals($P{sexe}))[/code]

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

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...