MicroStrategy ONE
OLAPAvg
Returns the average of the current value, preceding values, and succeeding values as defined in the function arguments. Unlike RunningAvg and MovingAvg which can only include values above the current row in the calculation, you can use OLAPAvg to include values both above and below the current row in the calculation.
The calculations can be restarted based on attributes defined in the function parameters.
Syntax
OLAPAvg<Distinct, OLAPWinStType, OLAPWinStOffset, OLAPWinEndType, OLAPWinEndOffset, BreakBy, SortBy>(Argument)
where
-
Distinct is a TRUE/FALSE parameter that allows you to use all values in the calculation or to calculate using only the unique values. If you define Distinct to be true, then the parameters OLAPWinStType, OLAPWinStOffset, OLAPWinEndType, OLAPWinEndOffset, and SortBy are ignored.
-
BreakBy is the attribute indicating where the calculation restarts.
-
SortBy is the attribute or metric by which the data is sorted.
-
OLAPWinStType defines the window type for the starting location of the calculation. You have the following options, listed by the name of the setting and its corresponding OLAPWinStType value in parentheses:
-
Top of dataset (0): The calculation starts at the top value as determined by theBreakByand SortBy values.
-
Current row (2): The calculation starts at the current row.
-
N rows before current row (3): The calculation starts a number of rows before the current row. You define this offset of rows with the OLAPWinStOffset parameter described below.
-
N rows after current row (4): The calculation starts a number of rows after the current row. You define this offset of rows with the OLAPWinStOffset parameter described below.
-
-
OLAPWinStOffset defines the offset of rows from the current row to start the calculation. You can define this offset if the OLAPWinStType parameter is defined as N rows before current row (3) or N rows after current row (4).
-
OLAPWinEndType defines the window type for the ending location of the calculation. You have the following options, listed by the name of the setting and its corresponding OLAPWinEndType value in parentheses:
-
Bottom of dataset (1): The calculation stops at the bottom value. The top value is determined by the BreakBy and SortBy values.
-
Current row (2): The calculation stops at the current row.
-
N rows before current row (3): The calculation stops a number of rows before the current row. You define this offset of rows with the OLAPWinEndOffset parameter described below.
-
N rows after current row (4): The calculation stops a number of rows after the current row. You define this offset of rows with the OLAPWinEndOffset parameter described below.
-
-
OLAPWinEndOffset defines the offset of rows from the current row to stop the calculation. You can define this offset if the OLAPWinEndType parameter is defined as N rows before current row (3) or N rows after current row (4).
-
Argument is a metric representing a list of numbers.
The function is not valid if your starting point is at a lower point than your ending point.
For additional information on and an example of this function, refer to the MicroStrategy Functions Reference.