EARLIEST DAX Function Not recommended
Returns the value in the column for the very first point at which there was a row context.
Syntax
Parameter | Attributes | Description |
---|---|---|
ColumnName |
The column that contains the desired value. |
Return values
The current value of row, from ColumnName, at the outermost row context.
Remarks
EARLIEST retrieves the value from the outermost row context.
It is recommended using variable (VAR) saving the value when it is still accessible, before a new row context hides the required row context to access the desired value.
» 1 related function
Examples
-- EARLIER evaluates a column in the outer row context, in case there -- are multiple row contexts open in the same expression -- -- EARLIER accepts a second argument that represents the number of steps -- EARLIEST retrieves the first ever row context EVALUATE ADDCOLUMNS ( VALUES ( Customer[Yearly Income] ), "Customers", CALCULATE ( COUNTROWS ( Customer ) ), "RT Customers", COUNTROWS ( FILTER ( Customer, Customer[Yearly Income] <= EARLIEST ( Customer[Yearly Income] ) ) ) ) ORDER BY [Yearly Income]
Yearly Income | Customers | RT Customers |
---|---|---|
10,000 | 1,155 | 1,155 |
20,000 | 1,767 | 2,922 |
30,000 | 2,287 | 5,209 |
40,000 | 2,747 | 7,956 |
50,000 | 670 | 8,626 |
60,000 | 3,127 | 11,753 |
70,000 | 2,349 | 14,102 |
80,000 | 1,342 | 15,444 |
90,000 | 842 | 16,286 |
100,000 | 571 | 16,857 |
110,000 | 474 | 17,331 |
120,000 | 332 | 17,663 |
130,000 | 512 | 18,175 |
150,000 | 103 | 18,278 |
160,000 | 94 | 18,372 |
170,000 | 112 | 18,484 |
10,000,000 | 385 | 18,869 |
-- EARLIEST is superseeded by a careful usage of variables. -- It is a best practice to avoid using EARLIER to make the code easier -- to author and maintain. EVALUATE ADDCOLUMNS ( VALUES ( Customer[Yearly Income] ), "Customers", CALCULATE ( COUNTROWS ( Customer ) ), "RT Customers", VAR CurrentYearlyIncome = Customer[Yearly Income] RETURN COUNTROWS ( FILTER ( Customer, Customer[Yearly Income] <= CurrentYearlyIncome ) ) ) ORDER BY [Yearly Income]
Yearly Income | Customers | RT Customers |
---|---|---|
10,000 | 1,155 | 1,155 |
20,000 | 1,767 | 2,922 |
30,000 | 2,287 | 5,209 |
40,000 | 2,747 | 7,956 |
50,000 | 670 | 8,626 |
60,000 | 3,127 | 11,753 |
70,000 | 2,349 | 14,102 |
80,000 | 1,342 | 15,444 |
90,000 | 842 | 16,286 |
100,000 | 571 | 16,857 |
110,000 | 474 | 17,331 |
120,000 | 332 | 17,663 |
130,000 | 512 | 18,175 |
150,000 | 103 | 18,278 |
160,000 | 94 | 18,372 |
170,000 | 112 | 18,484 |
10,000,000 | 385 | 18,869 |
Related articles
Learn more about EARLIEST in the following articles:
-
Variables in DAX
In this article, you learn a new feature in DAX 2015: variables. The 2015 version of the DAX language has many new functions, but none of them is a game changer for the language as variables are. » Read more
-
DAX coding style using variables
This article shows how variables in DAX can impact the coding style, simplifying a step-by-step approach and improving the readability of your code. » Read more
Related functions
Other related functions are:
Last update: Nov 14, 2024 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
Microsoft documentation: https://docs.microsoft.com/en-us/dax/earliest-function-dax