soham Posted December 10, 2009 Share Posted December 10, 2009 I have a master report which should add all the sub report totals. So, each sub report returns its total to the main report. Here is the master report's layout.Title band : SR1total variable( Calculation type - System, Reset type - Report)SR2total variable(Same as above)Detail band:SR1(Returning GrandTotal to SR1total); GrandTotal's Calulation type is Sum with initialValue as 0.00SR2(Returning GrandTotal to SR2total); GrandTotal's Calulation type is Sum with initialValue as 0.00When there is no data for a sub report(No pages on no data), i am trying to return the GrandTotal as 0.00, but, it returns null. Is there anyway i could return 0.00?Also, i was not able to store the addition of SR totals into a masterreport variable(tried System and nothing Calc types). I could print the additon using a text field in the title band. But, cannot put the same expression in a variable and use that variable to print in the same location. I need to use this grand total repeatedly in the master report, and i have 5 subreports. If i can't store this in a variable, i will have to use the expression $V{1}+$V{2}+$V{3}+$V{4}+${5} in several locations such as conditional styles etc.JR version: 3.5.0IReport version: 2.0.5Report language: Groovy Any help would be appreciated. Thanks--Naveen Link to comment Share on other sites More sharing options...
lucianc Posted December 14, 2009 Share Posted December 14, 2009 sohamWrote: When there is no data for a sub report(No pages on no data), i am trying to return the GrandTotal as 0.00, but, it returns null. Is there anyway i could return 0.00? Try to set 0 as initialValueExpression for the subreport variable. Also, i was not able to store the addition of SR totals into a masterreport variable(tried System and nothing Calc types). I could print the additon using a text field in the title band. But, cannot put the same expression in a variable and use that variable to print in the same location. I need to use this grand total repeatedly in the master report, and i have 5 subreports. If i can't store this in a variable, i will have to use the expression $V{1}+$V{2}+$V{3}+$V{4}+${5} in several locations such as conditional styles etc. Using variables with values returned from subreport in other variables' expression will not work. What you can do is to have total variable where you sum the values at the moment they are returned from subreports. See below.Regards,LucianCode:<variable name="SubTotal" calculation="System"/><returnValue subreportVariable="SubVar1" toVariable="SubTotal" calculation="Sum"/><returnValue subreportVariable="SubVar2" toVariable="SubTotal" calculation="Sum"/><returnValue subreportVariable="SubVar3" toVariable="SubTotal" calculation="Sum"/>.. Link to comment Share on other sites More sharing options...
soham Posted December 14, 2009 Author Share Posted December 14, 2009 luciancWrote: soham Wrote: When there is no data for a sub report(No pages on no data), i am trying to return the GrandTotal as 0.00, but, it returns null. Is there anyway i could return 0.00? Try to set 0 as initialValueExpression for the subreport variable. I am already keeping the initialValueExpession as 0.00(report language groovy). For some reason, the subreport seems to override the initialvalueExpression and replaces it with null. I also noticed that if i set to nodata type to "AllSectionsNoDetail", then, the engine returns the 0.00. Also, i was not able to store the addition of SR totals into a masterreport variable(tried System and nothing Calc types). I could print the additon using a text field in the title band. But, cannot put the same expression in a variable and use that variable to print in the same location. I need to use this grand total repeatedly in the master report, and i have 5 subreports. If i can't store this in a variable, i will have to use the expression $V{1}+$V{2}+$V{3}+$V{4}+${5} in several locations such as conditional styles etc. Using variables with values returned from subreport in other variables' expression will not work. What you can do is to have total variable where you sum the values at the moment they are returned from subreports. See below. Regards, Lucian Code: Sounds great. I will try this. Never thought about the calculation attribute of return value. Thanks,Naveen Link to comment Share on other sites More sharing options...
lucianc Posted December 22, 2009 Share Posted December 22, 2009 Indeed, the initial value expression of the variable is not invoked when the subreport has whenNoDataType="NoPages".As a workaround, you can use whenNoDataType="NoDataSection" (and do not include any no data section in the report). This way you'll not get any report output and the variable initial value will be used.Regards,Lucian Link to comment Share on other sites More sharing options...
therockita Posted April 22, 2010 Share Posted April 22, 2010 This was very useful for me too. Thank you Link to comment Share on other sites More sharing options...
map_1 Posted February 18, 2015 Share Posted February 18, 2015 Thanks a lot! This works for me! 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