This topic is locked

Implementing Running Totals In Asprunnerpro

6/7/2013 5:27:54 PM
ASPRunnerPro Tips and tricks
admin

As Wikipedia says "running total is the summation of a sequence of numbers which is updated each time a new number is added to the sequence, simply by adding the value of the new number to the running total". It is also known as running sum or running balance.
Adding running total to one of list pages is really simple. Lets consider table Balance with fields ID and Amount.
1.Modify SQL query adding a calculated Total field:

SELECT

ID,

Amount,

0 as Total

from Balance


2. Events Editor, Balance table: BeforeProcessList event:

SESSION("Total")=0


We are going to accumulate the current total amount in session variable SESSION("Total"). This variable needs to be reset when page is loaded.
3. 'Total' field in Visual Editor. Set 'View as' type to 'Custom' and use the following code:

SESSION("Total") = SESSION("Total") + CSmartDbl(data("Amount"))

strValue = SESSION("Total")


This is it. Here is how it looks in live application.