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

Subreport return values when no data


soham

Recommended Posts

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.00

SR2(Returning GrandTotal to SR2total); GrandTotal's Calulation type is Sum with initialValue as 0.00


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?

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.0

IReport version: 2.0.5

Report language: Groovy

 

Any help would be appreciated. Thanks

--Naveen

 


 

 

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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.

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:
<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

lucianc
Wrote:

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

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

  • 3 months later...
  • 4 years later...

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...