Running Sum
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
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.
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
Chan Kuan Leang
Running Sum
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
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
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
Thanks. It helps.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
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
Chan Kuan Leang
Running Sum
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
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
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
Thanks for your help.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
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
Chan Kuan Leang
Running Sum
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
I would try BeforePrint of the groupband or
BeforePrint of the text component inside the group band.
Let me know if it works..
Marco
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
Thank you so much!!!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
It is working now.!! Finally!!!

:biggrin:
Smile
Chan Kuan Leang
Chan Kuan Leang
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
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
Please help me on that.
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.
Smile
Chan Kuan Leang
Chan Kuan Leang
Running Sum
Is your variable called 'unit'?
Try changing that name, cause unit is already a member in the StiReport Class.
Marco
Try changing that name, cause unit is already a member in the StiReport Class.
Marco
-
- Posts: 74
- Joined: Sun May 20, 2007 9:14 pm
- Location: Singapore
Running Sum
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.
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
Chan Kuan Leang