MicroStrategy ONE

RunningAvg (Running Average)

Moves through the values in a list and returns the running average, adding the current value to the sum of the preceding values and dividing by the current count of values. The calculation can restart based on attribute groupings identified in the parameter settings. This is an OLAP function.

Syntax

RunningAvg <BreakBy,SortBy>(Argument)

Where:

  • BreakBy is the attribute indicating where the calculation restarts.
  • SortBy is the attribute or metric by which the data is sorted.
  • Argument is a metric representing a list of numbers.

Expression

Where:

  • yi = metric value at the ith row
  • m = window size
  • n = number of rows/metric values

Example

This simple example illustrates how the RunningAverage function walks through a list of values calculating and returning the new average with the addition of each value. The calculation is shown in the following table.

Values RunningAverage

10

10 (10/1)

20

15 (30/2)

30

20 (60/3)

40

25 (100/4)

50

30 (150/5)