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!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have a table called Performance which has many columns. The main columns are Acc, MonthEndDate and Flag.
For each Acc there is a row for each MonthEndDate. I'd like to bring back the flag for the most recent MonthEndDate for each Acc.
Example:
Have
Acc | MonthEndDate | Flag |
1 | 31/07/2022 | 0 |
1 | 31/08/2022 | 1 |
1 | 30/09/2022 | 1 |
1 | 31/10/2022 | 0 |
2 | 31/08/2022 | 0 |
2 | 30/09/2022 | 0 |
2 | 31/10/2022 | 1 |
Want
Acc | Flag |
1 | 0 |
2 | 1 |
Thanks
Solved! Go to Solution.
If you know that there will be 1 entry per Acc for every date then you can use
Most recent flag =
VAR MaxDate =
MAX ( 'Table'[Date] )
VAR ReferenceAcc =
SELECTEDVALUE ( 'Table'[Acc] )
VAR Result =
LOOKUPVALUE (
'Table'[Flag],
'Table'[Acc], ReferenceAcc,
'Table'[Date], MaxDate
)
RETURN
Result
If you know that there will be 1 entry per Acc for every date then you can use
Most recent flag =
VAR MaxDate =
MAX ( 'Table'[Date] )
VAR ReferenceAcc =
SELECTEDVALUE ( 'Table'[Acc] )
VAR Result =
LOOKUPVALUE (
'Table'[Flag],
'Table'[Acc], ReferenceAcc,
'Table'[Date], MaxDate
)
RETURN
Result