Page 1 of 1

Grouped + Percent

Posted: Mon May 09, 2011 2:16 am
by StimFan
Hi there :)

I have a DataBand with data like this:

Code: Select all

Nr.         Name                   Bought
1            ABC                     2
1            ABC                     8
1            ABC                     4
2            DEF                      2
2            DEF                      7
I want them to be grouped (I use a GroupHeader above the DataBand) -> works perfect. Looks like this:

Code: Select all

1            ABC                     2
2            DEF                      2
But now i want the Bought Column to sum each duplicate and an adittional column which shows the percentage like this:

Code: Select all

Nr.         Name                    Total    Percent
1            ABC                     14        60,8
2            DEF                      9         39,2
Is there a way in Reports.NET to do this?

Regards,

StimFan :biggrin:

Grouped + Percent

Posted: Mon May 09, 2011 3:39 am
by StimFan
Ok the total amount is no problem. But how do I get the percentage? When running SumRunning I get the 100% at the End, but I need it for each row to calculate the percentage.

Grouped + Percent

Posted: Mon May 09, 2011 5:01 am
by StimFan
Ok I think I got it:

- Add two variables:
totalAmount -> default value = 0
sumAdd -> default value = 0

In the Render event of the DataBand add this:
sumAdd += bought

And in the EndRender event add this:
totalAmount = sumAdd

Now I can calculate the percentage with this expression:
{Sum(bought)/(decimal)totalAmount*100}
for each Grouped Row...

I hope this will work still in subReports :S

Regards,
StimFan

Grouped + Percent

Posted: Tue May 10, 2011 4:26 am
by Alex K.
Hello,

Do I understand you correct that the issue is solved?

Thank you.