MicroStrategy ONE
FirstInRange
Returns the first value in a range of values. FirstInRange can be used to examine data such as inventory at the beginning of each month.
Calculations can be restarted based on attributes set in the function parameters. This restart capability differentiates FirstInRange from First. While First is a group-value function and takes both facts and metrics as argument input, FirstInRange is an OLAP function and takes only metrics as argument input.
Syntax
FirstInRange <BreakBy, SortBy> (Argument)
Where:
BreakByis the attribute indicating where the calculation restarts.SortByis the attribute or metric by which the data is sorted.Argumentis a metric representing a list of numbers.
Expression
Where:
k= row numbery1= first non-NULL value of the metric after applying theBreakByandSortByparameters
Example
This example shows the results of using the FirstInRange function. The report includes the attributes Customer Region and Customer State and the metrics Profit and FirstInRange. A report filter limits the regions displayed to Northwest, Southeast, and Southwest. The FirstInRange metric is defined as follows:
FirstInRange<BreakBy={[Customer Region]}, SortBy= ([Customer State]) >(Profit)
In the following report, FirstInRange returns the first profit value in the list of Customer States for each Customer Region.
