MicroStrategy ONE

MovingMax (Moving Maximum)

Returns the moving maximum value by comparing current and preceding rows as defined in the function arguments. The calculation can be restarted based on attributes set in the function parameters. This is an OLAP function.

Syntax

MovingMax <BreakBy, SortBy> (Argument, WindowSize)

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.
  • WindowSize is a positive integer indicating the number of values to compare in each calculation.

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 MovingMaximum function moves through a list of values, subtracting a value from the user-defined number of preceding rows. In this case, the window size is set to 3, meaning that the value in the MovingMaximum column represents the highest value among the current and preceding two values in the value list. The calculation is shown in the following table.

Values MovingMaximum

550

550

30

550 (550>30)

40

550 (550>40 and 550>30)

70

70 (70>40 and 70>30)

50

70 (70>50 and 70>40)