Skip to main content Skip to complementary content

Last - chart function

Last() returns the value of an expression evaluated with a pivot table's dimension values as they appear in the last column of the current row segment in the pivot table. This function returns NULL in all chart types except pivot tables.

Information noteSorting on y-values in charts or sorting by expression columns in tables is not allowed when this chart function is used in any of the chart's expressions. These sort alternatives are therefore automatically disabled. When you use this chart function in a visualization or table, the sorting of the visualization will revert back to the sorted input to this function.

Syntax:  

Last([TOTAL] expr [, offset [, count]])

Arguments
Argument Description
expr The expression or field containing the data to be measured.
offset Specifying an offset n, greater than 1 moves the evaluation of the expression n columns to the left from the last column.

Specifying an offset of 0 will evaluate the expression on the last column of the current row segment.

Specifying a negative offset number makes the Last function work like the First function with the corresponding positive offset number.

count By specifying a third parameter count greater than 1, the function will return a range of values, one for each of the table columns up to the value of count, counting to the left from the original cell.
TOTAL If the table is one-dimensional or if the qualifier TOTAL is used as argument, the current column segment is always equal to the entire column.

Defining the aggregation scope

If the pivot table has multiple horizontal dimensions, the current row segment will include only columns with the same values as the current column in all dimension rows except for the row showing the last horizontal dimension of the inter-field sort order. The inter-field sort order for horizontal dimensions in pivot tables is defined simply by the order of the dimensions from top to bottom.

Example: Chart expressions
Example Result
Last( Sum(Sales )) Returns the sum of Sales from the last column of the current row segment.
Last( Sum(Sales ), 2) Returns the sum of Sales from the column that is two columns to the left of the last column in the current row segment.
Last( Total Sum( Sales )) Returns the total sum of Sales from the last column of the current row segment.
RangeAvg (Last(Sum(x),1,5)) Returns an average of the results of the sum(x) function evaluated on the five rightmost columns of the current row segment.

Example - Last fundamentals

Example - Last scenario

Example - Using Last to calculate budget variance

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!