Insert Running Total

Figure 1 – Insert Running Total button, highlighted

A running total, also known as a cumulative sum, is the sum of a sequence of numbers or values as you progress through a dataset. In the case of an m-Power application, this is calculated by adding a value from the current row to the sum of the previous row(s) values.

The ability to compute a running total option is available from the m-Painter editor. Once a TABLE CELL element has been clicked in the m-Painter editor, the “Insert Running Total” option will appear, as shown in Figure 1.

Walkthrough

Using a regular report template for example, a running total can be added to the end of the report to show a running total of the Quantity Ordered, for each detail record.

Inserting a running total

From m-Painter, the running total can be inserted into a new column of the presentation, or into an existing column already in the report.

In either case, a table cell must be selected first and then the “Insert Running Total” option will be selected, as shown in Figure 3.

In the popup window that appears, the developer will configure the running total feature.

The two options shown in Figure 4 are as follows:

  • Field to Total – This is required. Select the numeric field which will be computed as a running total.
  • Reset the total each time this field’s value changes (Optional) – If the running total should reset back to 0 based on another field in the application, then select that dependent field here. By not selecting a dependent field, the running total will continually sum until the last record on the page is reached.

In the example presented above, the field to be running totaled is the quantity ordered and no dependent field is selected.

After pressing “Apply” the m-Painter editor will display some logic in the cell to indicate a running total value has been placed, such as this:

{runningTotal(row,"OQTY")}

Editing or Deleting a running total

If needing to edit the running total configuration ever, click on the code in the cell. m-Painter will identify the element as a “DATA-FIELD”, where then the option to press “Edit Running Total” will appear, as shown in Figure 5.

To delete a running total value, select the trash can icon to perform the deletion of the DATA-FIELD element; which in this case is a running total value. Use Figure 5 for a visual clarification.

Runtime Demonstration (finished example)

At runtime, the running total feature will look similar to this, where the numeric field (in this case, quantity ordered) is continually summed on each new detail record:

Updated on March 20, 2025

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support