using variable to calculate TOTAL
using variable to calculate TOTAL
I have a report with the following structure:
Header
Group Header
Data Band
Group Footer
Footer
Now Data band has an amount being displayed and I use a variable to calculate total for each group, So on Data Band Rendering:-
vTotal += dsBQItem.REVISEDAMT;
My Requirement is I display this on Group Header, Not on Group footer.
I do not want to use SUM function..
However the variable vTotal is not calculated yet when group header is printed. so always it gets printed as 0.
It gets calculated only when data band is actually printed, but by this time group header was already printed with a 0 vTotal variable.
How can I achieve this requirement? Is it possible to do that?
Thanks
Header
Group Header
Data Band
Group Footer
Footer
Now Data band has an amount being displayed and I use a variable to calculate total for each group, So on Data Band Rendering:-
vTotal += dsBQItem.REVISEDAMT;
My Requirement is I display this on Group Header, Not on Group footer.
I do not want to use SUM function..
However the variable vTotal is not calculated yet when group header is printed. so always it gets printed as 0.
It gets calculated only when data band is actually printed, but by this time group header was already printed with a 0 vTotal variable.
How can I achieve this requirement? Is it possible to do that?
Thanks
Re: using variable to calculate TOTAL
Hello,
In this vase, you can use the Double Pass. In the first pass calculate all necessary values and in the second pass show it.
Thank you.
In this vase, you can use the Double Pass. In the first pass calculate all necessary values and in the second pass show it.
Thank you.
Re: using variable to calculate TOTAL
How does Double Pass work?
So when I do double pass, first time all the calculations are done, in second pass, aren't they set back to 0?
How does it know the total for each group on the second pass?
Thanks
So when I do double pass, first time all the calculations are done, in second pass, aren't they set back to 0?
How does it know the total for each group on the second pass?
Thanks
Re: using variable to calculate TOTAL
Hello,
You can use an array or a hashtable for storage the calculated value.
For example
Please check the sample report in the attachment. You could find additional code in BeforePrint events of the GrouipHeadr and DataBand.
Thank you.
You can use an array or a hashtable for storage the calculated value.
For example
Code: Select all
if (IsFirstPass)
{
vTotal += dsBQItem.REVISEDAMT;
hashTable[GroupHeaderValue] = vTotal;
}
Thank you.
- Attachments
-
- ReportSample.mrt
- (21.76 KiB) Downloaded 282 times
Re: using variable to calculate TOTAL
thanks Aleksey, i will try this.
Re: using variable to calculate TOTAL
Hello
Ok.
Let us know if you need any additional help.
Thank you.
Ok.
Let us know if you need any additional help.
Thank you.