Page 1 of 2

Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 4:58 am
by prajan
Hi,
I have a report with two sub reports. I need to get the sum of columns from each of the sub report to be shown in the main report.
Can you please let me know how this can be handled?

Thanks

Re: Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 7:33 am
by Alex K.
Hello,

Please send us your report with test data for analysis.
Also please try to use the Totals.Sum() function.

Thank you.

Re: Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 8:53 am
by prajan
Hi,
PFA the report and the data for the report.
Currently I am getting the sub report column totals in the sub-report itself.
I would like to get these totals in a Footer in the main report so that both the totals come at the end of the report.

Thanks

Re: Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 1:02 pm
by Alex K.
Hello,

In this case, as a way, you can use the additional variables and DoublePass. In first pass you can calculate necessary sum by column, sets value for variable and use these variables on main page.

Thank you.

Re: Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 1:30 pm
by prajan
Can you please give an example as to how to use Double pass?

Thanks

Re: Sum a column in subreport and show in main report

Posted: Fri May 17, 2013 1:41 pm
by Alex K.
Hello,

Please check the sample report in the attachment.

Thank you.

Re: Sum a column in subreport and show in main report

Posted: Mon May 20, 2013 3:58 am
by prajan
Hi,
I checked the report, but didn't understand what the {SumSubReport} actually calculated. How is it taking any value from the sub-report?
If I use the same in my report, I get the following error :
"error CS0103: The name 'SumSubReport' does not exist in the current context"
Please let me know how to resolve the same.

Thanks

Re: Sum a column in subreport and show in main report

Posted: Mon May 20, 2013 5:53 am
by Alex K.
Hello,

Please check the BeforePrint event of DataBand on SubReport. In this event calculating the value for SumSubReport variable.

Thank you.

Re: Sum a column in subreport and show in main report

Posted: Mon May 20, 2013 10:25 am
by prajan
Hi,
Thanks for the help. It worked.
But I didn't give the if(IsFirstpass) condition. Is that ok? Or will it cause a performance issue?
Please let me know.
Thanks.

Re: Sum a column in subreport and show in main report

Posted: Mon May 20, 2013 10:54 am
by Alex K.
Hello,

It is for correct calculation of value. In the first pass we get the value and in second show it.

Thank you.