Forums: Implementing Running Totals In Asprunnerpro - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Implementing Running Totals In Asprunnerpro

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16045
  • Joined: 03-February 03

Posted 07 June 2013 - 09:27 PM

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.

Posted Image
Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic