Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Dear Power BI heroes,
I have a question regarding the EARLIER function. I have the following DAX query:
Solved! Go to Solution.
@Anonymous
An alternative version that uses EARLIER as you initially intended:
Unieke waarde V3 =
CALCULATE (
DISTINCTCOUNT ( 'AUDIT line'[Amnt] ),
FILTER (
ALL ( 'AUDIT line' ),
CALCULATE (COUNT ( 'AUDIT line'[Amnt] ), 'AUDIT line'[Amnt] = EARLIER('AUDIT line'[Amnt] ), ALL('AUDIT line')) = 1
)
)
or the same using variables instead of EARLIER, which is recommended nowadays:
Unieke waarde V3B =
CALCULATE (
DISTINCTCOUNT ( 'AUDIT line'[Amnt] ),
FILTER (
ALL ( 'AUDIT line' ),
VAR amnt_ = 'AUDIT line'[Amnt]
RETURN
CALCULATE (COUNT ( 'AUDIT line'[Amnt] ), 'AUDIT line'[Amnt] = amnt_ , ALL('AUDIT line')) = 1
)
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
@Anonymous
or yet another, more elegant, option:
Unieke waarde V4 =
COUNTROWS(
FILTER (
ALL ( 'AUDIT line'[Amnt] ),
CALCULATE (COUNT ( 'AUDIT line'[Amnt] )) = 1
)
)
Unieke waarde V5 =
SUMX (
ALL ( 'AUDIT line'[Amnt] ),
1*(CALCULATE (COUNT ( 'AUDIT line'[Amnt] )) = 1)
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
@Anonymous
An alternative version that uses EARLIER as you initially intended:
Unieke waarde V3 =
CALCULATE (
DISTINCTCOUNT ( 'AUDIT line'[Amnt] ),
FILTER (
ALL ( 'AUDIT line' ),
CALCULATE (COUNT ( 'AUDIT line'[Amnt] ), 'AUDIT line'[Amnt] = EARLIER('AUDIT line'[Amnt] ), ALL('AUDIT line')) = 1
)
)
or the same using variables instead of EARLIER, which is recommended nowadays:
Unieke waarde V3B =
CALCULATE (
DISTINCTCOUNT ( 'AUDIT line'[Amnt] ),
FILTER (
ALL ( 'AUDIT line' ),
VAR amnt_ = 'AUDIT line'[Amnt]
RETURN
CALCULATE (COUNT ( 'AUDIT line'[Amnt] ), 'AUDIT line'[Amnt] = amnt_ , ALL('AUDIT line')) = 1
)
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @Anonymous
If this is a measure, there is no previous/earlier row context in your code that EARLIER can refer to and thus fails.
I assume you are trying to calculate the number of values in the 'AUDIT line'[Amnt] column that appear only once in the table. If so:
Unieke waarde V2 =
CALCULATE (
DISTINCTCOUNT ( 'AUDIT line'[Amnt] ),
FILTER (
ALL ( 'AUDIT line' ),
CALCULATE (COUNT ( 'AUDIT line'[Amnt] ), ALLEXCEPT ( 'AUDIT line', 'AUDIT line'[Amnt] )) = 1
)
)
|
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
@Anonymous There's no row context for EARLIER to operate on that provides that column. You could do this instead:
VAR __Amnt = MAX('AUDIT line'[Amnt])
VAR __Result =
CALCULATE(
DISTINCTCOUNT('AUDIT line'[Amnt]),
FILTER(
ALL('AUDIT line'),
'AUDIT line'[Amnt] = __Amnt
)
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 16 | |
| 12 | |
| 9 | |
| 7 | |
| 6 |