The EARLIEST function is used in calculated columns and allows access to the value of a column (of the row being analyzed) in nested calculations, this value being the one corresponding to the outermost evaluation level.
EARLIEST(
column
)
- column: Column name or expression that returns a column.
The EARLIEST function returns the value of the current row in the column column corresponding to the outermost evaluation level.
In most cases it can be said that the EARLIEST function returns an access "to the current row".
If used in a measure, the function returns an error.
The EARLIEST function returns an error if there is no row context prior to parsing the table.
In this example we start from the following table, the result of adding the sales table by country and gender of the customer:
If we wanted to add a new column including the total sales for the country involved in the row being considered, we could achieve it with the following calculated field:
Ventas totales =
CALCULATE(
SUM(Tabla[Ventas]),
ALL(Tabla),
Tabla[Country]=EARLIEST(Tabla[Country])
)
Note that we need to involve the entire table in the calculation, for which we can use the ALL function. The result is as follows: