Grouped + Percent

Stimulsoft Reports.NET discussion
Post Reply
StimFan
Posts: 8
Joined: Thu Apr 07, 2011 2:35 am
Location: Germany

Grouped + Percent

Post 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:
StimFan
Posts: 8
Joined: Thu Apr 07, 2011 2:35 am
Location: Germany

Grouped + Percent

Post 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.
StimFan
Posts: 8
Joined: Thu Apr 07, 2011 2:35 am
Location: Germany

Grouped + Percent

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Grouped + Percent

Post by Alex K. »

Hello,

Do I understand you correct that the issue is solved?

Thank you.
Post Reply