MicroStrategy ONE

First and Last

The First and Last functions provide the ability to use sort-by inside aggregation functions, which are functions where the value depends on the sort order. First returns the First value in a sorted set of values, while Last returns the last value. You can define the sort attributes in the function parameters.

For example, an inventory report lists the on-hand supply for each day. The report subtotals are the last day's inventory. Creating a user-defined subtotal that uses the Last function provides the needed last day inventory subtotal. If the sort parameters of the function are not set to sort by Day, the function may not provide the correct answer.

For a sample scenario using the First function, see Defining Subtotal Defaults.