EARLIER/EARLIEST refers to an earlier row context which doesn't exist.
EARLIER was used without a surrounding (nested) row context to step back into.
Why it happens
- EARLIER used inside a measure, which has no row context.
- Only one row context is present — there's nothing 'earlier' to reference.
- The intent was to capture the current row's value, which a variable does more clearly.
How to fix it
- Use a variable instead:
VAR curr = Table[Col] RETURN COUNTROWS ( FILTER ( Table, Table[Col] < curr ) ). - If you do need EARLIER, ensure it sits inside a nested iterator (e.g. a
FILTERinside a calculated column). - Prefer VAR in all new code — it's readable and avoids this class of error entirely.
Fix
Rank = VAR curr = Sales[Amount] RETURN 1 + COUNTROWS ( FILTER ( Sales, Sales[Amount] > curr ) )