Running Total Functions
A running total is a calculation based on input values that are known so far.
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:
In this example, the Running Sum values provide insight 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:
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.