DAX Filter - EARLIER function



Description

Returns the current value of the specified column in an outer evaluation pass of the mentioned column.

Syntax

EARLIER (<column>, <number>) 

Parameters

Sr.No. Parameter & Description
1

column

A column or expression that resolves to a column.

2

number

Optional. A positive number to the outer evaluation pass.

  • The next evaluation level out is represented by 1.
  • Two levels out is represented by 2, and so on.

If omitted, default value is 1.

Return Value

The current value of row, from column, at number of outer evaluation passes.

Remarks

EARLIER is useful for nested calculations where you want to use a certain value as an input and produce calculations based on that input. In Microsoft Excel, you can do such calculations only within the context of the current row. However, in DAX you can store the value of the input and then make calculation using data from the entire table.

EARLIER is mostly used in the context of calculated columns. EARLIER succeeds if there is a row context prior to the beginning of the table scan. Otherwise, it returns an error.

Example

If you have a table Sales with sales data, you can create a calculated column with the ranks of the Sales Amount values as follows −

= COUNTROWS ( 
   FILTER (Sales, EARLIER (Sales[Sales Amount])<Sales[Sales Amount])
)+1 
dax_functions_filter.htm
Advertisements