Running Sum

Stimulsoft Reports.NET discussion
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

Hi,

Can I know how to do a running sum in Databand?

For example header "No, ItemID, ...

The "No" will add by itself starting from 1, 2 & so on.

hope you can understand.

Thanks.
Smile
Chan Kuan Leang
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Running Sum

Post by EDV Gradl »

One way to do it is like this:


Add a variable of type int to the report, start value is 0, lets say it is called MySum

Edit the RenderingEvent of the databand and add

MySum++;

Now you can print this sum in the databand:

{this.MySum}

I hope that helps.

Marco
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

EDV wrote:One way to do it is like this:


Add a variable of type int to the report, start value is 0, lets say it is called MySum

Edit the RenderingEvent of the databand and add

MySum++;

Now you can print this sum in the databand:

{this.MySum}

I hope that helps.

Marco
Thanks. It helps.

What about in GroupheaderBand?? Is it the same?
I have test it in groupheaderband, but instead of appearing 1,2,3... it appears as 1,2,5,13 & so on.

Thanks.
Smile
Chan Kuan Leang
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Running Sum

Post by EDV Gradl »

Correct berhaivor. The variable increments by on for every data row.

For use in Group Headerband, you need a second variable MySumGroup and you should you the rendering event of the group for the new variable.

Thanks, Marco
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

EDV wrote:Correct berhaivor. The variable increments by on for every data row.

For use in Group Headerband, you need a second variable MySumGroup and you should you the rendering event of the group for the new variable.

Thanks, Marco
Thanks for your help.
But, i seems not able to get the desired results.

I have try as below

Add a variable of type int to the report, start value is 1, & named it as MyGroupSum

Edit the RenderingEvent of the GroupHeaderBand and add

MyGroupSum++;

In the GroupHeaderBand:
{this.MyGroupSum}

But, the result is still the same... 1, 3, 4, 5....

Can you help on this? Thanks
Smile
Chan Kuan Leang
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Running Sum

Post by EDV Gradl »

Hmm, it seem that the event is called every timer, even if the Band is not printed.

I would try BeforePrint of the groupband or

BeforePrint of the text component inside the group band.

Let me know if it works..

Marco
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

EDV wrote:Hmm, it seem that the event is called every timer, even if the Band is not printed.

I would try BeforePrint of the groupband or

BeforePrint of the text component inside the group band.

Let me know if it works..

Marco
Thank you so much!!!

It is working now.!! Finally!!! :cry:

:biggrin:
Smile
Chan Kuan Leang
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

I have to to create the running sum again in the databand. But I failed using the same method as below in the post.

I do not know what wrong's with it.

It keeps giving errors as below

Code: Select all

 Exception Details: System.Exception: C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(57,0) : warning BC40004: variable 'Unit' conflicts with property 'Unit' in the base class 'StiReport' and should be declared 'Shadows'.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30454: Expression is not a method.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30800: Method arguments must be enclosed in parentheses.C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\d-gnyqzn.0.vb(201,0) : error BC30037: Character is not valid.
Please help me on that.

Smile
Chan Kuan Leang
EDV Gradl
Posts: 228
Joined: Sat Jun 17, 2006 9:50 am
Location: Germany

Running Sum

Post by EDV Gradl »

Is your variable called 'unit'?

Try changing that name, cause unit is already a member in the StiReport Class.

Marco
Chan Kuan Leang
Posts: 74
Joined: Sun May 20, 2007 9:14 pm
Location: Singapore

Running Sum

Post by Chan Kuan Leang »

EDV wrote:Is your variable called 'unit'?

Try changing that name, cause unit is already a member in the StiReport Class.

Marco

Code: Select all

C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30454: Expression is not a method.
C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30800: Method arguments must be enclosed in parentheses.
C:\Documents and Settings\Chan Kuan Leang\Local Settings\Temp\fs3mds9m.0.vb(197,0) : error BC30037: Character is not valid.
Hmm.. I have rename my textbox. But, it comes up with the above errors.
Please help on that.

I created a variable "MySum" int, Default Value = 0
Then in the databand, I have tried putting MySum++; in Before Render or Rendering Events & Before Print, it still comes up with the same errors.
Smile
Chan Kuan Leang
Post Reply