Running Totals

Stimulsoft Reports.NET discussion
Post Reply
robert
Posts: 6
Joined: Thu Mar 08, 2007 7:19 am
Location: France

Running Totals

Post by robert »

Sorry if this is a simple question, maybe I missing something, but how do I create a running total? I want to calculate a balance coloumn like:

Reason | Credit/Debit | Balance
---------+--------------+----------
XXX | 10.0 | 10.0
XXX | 10.0 | 20.0
XXX | 10.0 | 30.0

I see there is a section in the manual entitled "Calculation of a growing total" [1], but this doesn't make a huge amount of sense to me. Is this possible easily though the desiner GUI or do I have to write some C# code to achive this?

[1] http://www.stimulsoft.com/Documentation ... tarted.htm
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Running Totals

Post by Edward »

There exists two ways to calculate sums based on condition in the StiText component.

1. It is possible to calculate sums via SumIf function:
{SumIf(MyDataSource.MyDataColumn,Condition)}

2. Also this goal may be achieved via Totals.

Code: Select all

{IIF(Condition,Totals.Sum(MyDataSource,(Condition?MyDataSource.MyDataColumn:0))}
Sum by all data without taking into condition may be counted very simply.
For example you have DataBand1 with Data on it. In that case a result of calculating the balance my be achieved in the following way:

Code: Select all

{Sum(DataBand1,BalanceTable.Debet)-Sum(DataBand1,BalanceTable.Credit)}
This code you should also assign to the Text property of some StiText component.
Please note, that this component with sum calculated may be placed in any part of the report's page as in the Footer as well to the Header band.

Please see an example based on your data.

http://forum.stimulsoft.com/upload/Tota ... xample.zip

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Running Totals

Post by Edward »

Running totals without writing any code (as build-in function) is already in our to-do list.
When the function will be available, we will post a message in this topic.

Thank you.
Post Reply