KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to display a running total in a quick report
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: January 24, 2007

The following Tech Tip describes how to create the following:



As you can see the fourth column contains a running total. For the month of February, a total of 12 fishes were caught. Therefore, the total for Jan and Feb is 18 as displayed in the fourth column.

In order to display this running total, the following method was used in the formula for the column:
----------------------------------------------------------------
C_LONGINT($0;subt)

If (Selected record number([Table 1])=1)
   subt:=0
End if
subt:=[Table 1]Fisherman1+[Table 1]Fisherman2+subt

$0:=subt
----------------------------------------------------------------
NOTE: This is not a generic method. In order to use this in your structure you will need to replace the table and field references with ones that you have in your structure.

How to apply the method to a column with Quick Report:

-Create the column by selecting the Add.. item from the Columns menu.
-Double click the column you added to display the Formula Editor.
-In the empty line, put the method name which contains the above code. Click OK.



-Then click on the last row for the column and select the item Sum from the Cells menu.

That's it, your report should now have a running total along with a grand total.

Related Sources:

-Using Project Methods to Return Values to a Quick Report
http://www.4d.com/knowledgebase?CaseID=24616

-Accessing Project methods within the Formula Editor
http://www.4d.com/knowledgebase?CaseID=34719