SumRunning problem

Stimulsoft Reports.NET discussion
mrafieian
Posts: 8
Joined: Tue Jun 16, 2009 12:53 am

SumRunning problem

Post by mrafieian »

I use {SumRunning(DataBandName, MyDataSource.AmountColumn)} but I want to reset this sum to zero when group is change and recalculate the sum in new group as this sample

A(Group)
Column1 SumRunning(Column1)
1 1
2 3
3 6
4 10
5 15

B(Group)
Column1 SumRunning(Column1)
8 8
7 15
3 18
4 22
5 27

Please help me.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

SumRunning problem

Post by Andrew »

Hello,

Sum does not work in groups. You need to use the variables. You may read about it in our documentation http://stimulsoft.com/Documentation.aspx .

Thank you.
mrafieian
Posts: 8
Joined: Tue Jun 16, 2009 12:53 am

SumRunning problem

Post by mrafieian »

Helo

Thank you for your reply , can you give me more detail about what kind of variable I should use for this perpose?

Thanks
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

SumRunning problem

Post by Jan »

Hello,


====================

Using Stimulsoft Reports you may make calculation of aggregate functions in the code of events of a report. This allows calculating aggregate functions with complex logic or condition. Another advantage of Stimulsoft Reports is that, when calculating, you call the value to be calculated from the report code and make changes. If you want to make such a calculation, the variable which stores the value of an aggregate function is required. For this, you should create a new variable in the data dictionary.

Important! Using variables from the code to store the result of an aggregate function calculation is not allowed. It is necessary to use variables created in the dictionary.


Here you specify the type of a variable, for example Decimal, and the initial value is zero. Then in the Render event of the Data band you should set the code for a variable increment. For example, if you want to calculate the sum of variables of the Products.ItemsInStock field then the code will be as follows:


MyTotals += Products.ItemsInStock;


The RenderingEvent event

The Data band in what the RenderingEvent event calculation will be made

The code for calculating the sum



For calling the variable, that contains the value of a total, write in the following in the text expression:


{MyTotal}


If, after you have written the text expression, you run the report rendering. Then, when the report rendering will reach the component which contains the expression with the total variable, then there will be an output of this variable. Therefore, you should specify to the report generator that the component output must be done right after the whole report rendering - when the variable will be calculated completely. For this, you must set the ProcessAtEnd property of the text component to true.

Notice. Expressions of text components which the ProcessAtEnd properties are set to true are always calculated at the end of the report rendering.

As was written before the total will be calculated and shown in the proper part of a report.

====================

Thank you.
mrafieian
Posts: 8
Joined: Tue Jun 16, 2009 12:53 am

SumRunning problem

Post by mrafieian »

Helo,

Thanks a lot for your support , It's very usefull

Regards
AAA
Posts: 8
Joined: Tue Jul 07, 2009 11:40 pm
Location: dsda

SumRunning problem

Post by AAA »

Jan wrote:Hello,


====================

Using Stimulsoft Reports you may make calculation of aggregate functions in the code of events of a report. This allows calculating aggregate functions with complex logic or condition. Another advantage of Stimulsoft Reports is that, when calculating, you call the value to be calculated from the report code and make changes. If you want to make such a calculation, the variable which stores the value of an aggregate function is required. For this, you should create a new variable in the data dictionary.

Important! Using variables from the code to store the result of an aggregate function calculation is not allowed. It is necessary to use variables created in the dictionary.


Here you specify the type of a variable, for example Decimal, and the initial value is zero. Then in the Render event of the Data band you should set the code for a variable increment. For example, if you want to calculate the sum of variables of the Products.ItemsInStock field then the code will be as follows:


MyTotals += Products.ItemsInStock;


The RenderingEvent event

The Data band in what the RenderingEvent event calculation will be made

The code for calculating the sum



For calling the variable, that contains the value of a total, write in the following in the text expression:


{MyTotal}


If, after you have written the text expression, you run the report rendering. Then, when the report rendering will reach the component which contains the expression with the total variable, then there will be an output of this variable. Therefore, you should specify to the report generator that the component output must be done right after the whole report rendering - when the variable will be calculated completely. For this, you must set the ProcessAtEnd property of the text component to true.

Notice. Expressions of text components which the ProcessAtEnd properties are set to true are always calculated at the end of the report rendering.

As was written before the total will be calculated and shown in the proper part of a report.

====================

Thank you.
Can you give me 1 simple example?
i having problem when access Text SumRunning from code behind C#. Because i want read number to word from Text SumRunning.
Example: Text SumRunning after calculate is 300000000. How to access number 300000000 from code behind C#
Thanks
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

SumRunning problem

Post by Edward »

Hi

There is no such a problem to access a value which had been already rendered, as you can use a variable from Dictionary. So value of this variable is unchanged for every rendered databand row.

Please see the report in the attachment.


Thank you.
Attachments
200.RunningTotals.mrt
(14.7 KiB) Downloaded 720 times
AAA
Posts: 8
Joined: Tue Jul 07, 2009 11:40 pm
Location: dsda

SumRunning problem

Post by AAA »

Thanks Edward, but hoow to access variable MyVariable from Code Behind?
When i access variable MyVariable is emtpy
Code i used:
rpt.Dictionary.Variables["MyVariable"].Value

This is example (attach). How to access value txtTotalPrice after calculate
Attachments
201.Sample.mrt
(42.1 KiB) Downloaded 692 times
AAA
Posts: 8
Joined: Tue Jul 07, 2009 11:40 pm
Location: dsda

SumRunning problem

Post by AAA »

i want convert totalprice decimal to word same function ToCurrencyWords in Stimusoft report
but i need convert to Vietnam language.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

SumRunning problem

Post by Jan »

Hello,
khongminh9 wrote:Thanks Edward, but hoow to access variable MyVariable from Code Behind?
When i access variable MyVariable is emtpy
Code i used:
rpt.Dictionary.Variables["MyVariable"].Value

This is example (attach). How to access value txtTotalPrice after calculate
You can use following code:

Code: Select all

rpt["MyVariable"]
Thank you.
Post Reply