jhhenkel Posted August 18, 2011 Share Posted August 18, 2011 Hi guys,does anybody know if I can use a where-function in a variable?I want the variable to: sum FIELD1 where attribut1 = Xand later tosum FIELD1 where attribut1=Y Is this possible? Thanks a lot! Link to comment Share on other sites More sharing options...
cbarlow3 Posted August 18, 2011 Share Posted August 18, 2011 Sure. Define a variable called SumX with data type java.lang.Integer (or whichever data tyep is appropriate for summing FIELD1), set the calculation to "Sum", leave Reset type at "Report", set the Initial Value Expression to 0, and set the Variable Expression to attribut1 == x ? $F{FIELD1} : 0If you drag a copy of this variable into your summary band, it will show you the sum of the FIELD1 values for every detail band where attribute1==x (except that I don't really know what attribut1 is...I presume it's really a condition, not an attribute, and you'll replace that with some condition like $F{Status}=="Open") Then in the Report inspector, copy variable SumX and paste it so you have a new variable with exactly the same properties but a different name. In the properties pane, rename the variable to SumY and change the Variable Expression so it has the desired condition at the beginning ($F{Status}=="Closed", or something like that). Hope that helps! Carl Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now