EARLIEST
A column's value in the outermost row context.
Group: Filter. Compatible with DAX.
Syntax
EARLIEST ( <column> )
| Parameter | Type | Description |
|---|---|---|
column | Column | The column whose value in the outermost row context is wanted. |
Returns
Same type as the column. The column's value in the first row context, the one furthest out.
Remarks
- With two row contexts it reads the same row as
EARLIER. It differs only when three or more iterations over the same table are nested. - At least two row contexts that have the column must be open; otherwise it is an error.
- Variables make nested iterations easier to follow: keep the outer value in a VAR before the inner iterations begin.
Examples
Two row contexts: the same as EARLIER
EVALUATE
ADDCOLUMNS (
Products,
"Cheaper, EARLIER", COUNTROWS ( FILTER ( Products, Products[Price per liter] < EARLIER ( Products[Price per liter] ) ) ),
"Cheaper, EARLIEST", COUNTROWS ( FILTER ( Products, Products[Price per liter] < EARLIEST ( Products[Price per liter] ) ) )
)
ORDER BY Products[Price per liter]
| Products[Product] | Products[Category] | Products[Price per liter] | Cheaper, EARLIER | Cheaper, EARLIEST |
|---|---|---|---|---|
| Lettøl | Beer | 30 | (blank) | (blank) |
| Pils | Beer | 38 | 1 | 1 |
| Cider | Cider | 52 | 2 | 2 |
| IPA | Beer | 64 | 3 | 3 |
Three row contexts
The outer ADDCOLUMNS, a FILTER of the products of the same category, and a MAXX inside it. Seen from the innermost, EARLIER reads the FILTER's row, so the outer MAXX gives the category's last name in alphabetical order (Pils, for the beers). EARLIEST, like EARLIER with 2, reads the outer row: the product itself.
EVALUATE
ADDCOLUMNS (
Products,
"EARLIER",
MAXX (
FILTER ( Products, Products[Category] = EARLIER ( Products[Category] ) ),
MAXX ( Products, EARLIER ( Products[Product] ) )
),
"EARLIER ( , 2 )",
MAXX (
FILTER ( Products, Products[Category] = EARLIER ( Products[Category] ) ),
MAXX ( Products, EARLIER ( Products[Product], 2 ) )
),
"EARLIEST",
MAXX (
FILTER ( Products, Products[Category] = EARLIER ( Products[Category] ) ),
MAXX ( Products, EARLIEST ( Products[Product] ) )
)
)
ORDER BY Products[Product]
| Products[Product] | Products[Category] | Products[Price per liter] | EARLIER | EARLIER ( , 2 ) | EARLIEST |
|---|---|---|---|---|---|
| Cider | Cider | 52 | Cider | Cider | Cider |
| IPA | Beer | 64 | Pils | IPA | IPA |
| Lettøl | Beer | 30 | Pils | Lettøl | Lettøl |
| Pils | Beer | 38 | Pils | Pils | Pils |
Related functions
EARLIER, FILTER, ADDCOLUMNS, MAXX.