Running Total Functions

A running total is a calculation based on input values that are known so far.

Examples

In the following table, you can see that a running summation total (RUNSUM) is calculated for the values in the Units column that have occurred up to the current date, yielding a Month to Date (MTD) calculation. When this column is added to a running sum across months, a YTD calculation is available:

DateUnitsMTDYTD
05/28/2014277191
05/29/2014380194
05/30/2014686200
06/02/201422202
06/03/201435205
06/04/201416206
06/05/201428208
06/06/2014311211
06/09/2014415215
06/10/2014116216
06/11/2014319219

In this example, the Running Sum values provide a visualization into the total Units that have been recorded so far for the month and year. Running total functions provide an effective method for creating snapshots of metric values over an interval of date or attribute values.

For example, you can use running totals to identify how Sales are tracking toward expected goals for the reporting period. The following table renames the columns of the previous table and adds new columns to support this Sales example:

DateSalesMTDExpected MTDDifference
05/28/201427775+2
05/29/2014380800
05/30/201468685+1
06/02/20142220
06/03/2014354-1
06/04/20141660
06/05/20142880
06/06/201431110+1
06/09/201441512+3
06/10/201411614+2
06/11/201431916+3

Running total functions can be created like any other metric and have broad application across a variety of transactional data.

  • Running totals can be computed for multiple types of aggregation functions. Supported running functions include average minimum, maximum, and sum, as well as statistical functions such as standard deviation and variance.
  • In addition to date dimensions, some running totals can be applied to known values of attributes through the secondary-click menu.

Using running totals and WITHIN keyword

The WITHIN keyword can be applied to MAQL definitions of running total metrics to specify the scope within which running totals are maintained. For example, if you add WITHIN (Quarter) to your MAQL definition for your running total metric, the total is maintained throughout a quarter and restarts calculation at the start of the next quarter.