MicroStrategy ONE

Lag

The Lag function is useful to display a set of metric values in an order determined by another metric or attribute on the report. This allows you to compare metric values side-by-side. The easiest way to understand the Lag function is with an example, which one is provided below.

Syntax

Lag <BreakBy, SortBy> (Argument, Offset, DefaultValue)

where

  • BreakBy is the attribute indicating where the calculation restarts.

  • SortBy is the attribute or metric by which the data is sorted.

  • Argument is an attribute or metric representing a list of values. It is common to use a metric for Argument.

  • Offset specifies the offset from the current row to display information for. This offset trails behind the current row (you can use the Lead function to use an offset that precedes ahead of the current row). For example, with an offset of two, row three displays data for the row two behind it, which would be row one.

  • DefaultValue is the value displayed for any entries that do not have any data due to the offset. For example, when using an offset of two, the first two entries use the default value.

    It is common to enter a value of 0 or NULL for the DefaultValue.

For additional information on and an example of this function, refer to the MicroStrategy Functions Reference. This resource also includes an example of using the Lag and Lead functions to perform transformation-style analysis.