Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi!
I have a dataset that looks like this:
C_ID DATE
1 01/01/2022
2 02/01/2022
2 03/01/2022
3 04/01/2022
4 06/01/2022
4 05/01/2022
I need to create a calculated column that shows true if it's the latest of each ID, like this:
C_ID DATE isTheLatestOfId
1 01/01/2022 True
2 02/01/2022 False
2 03/01/2022 True
3 04/01/2022 True
4 06/01/2022 True
4 05/01/2022 False
Is there a way I can do this with DAX?
So far I managed to obtain the latest of all of them like this:
isTheLatestOfId= IF(CALCULATE(MAX(T1[Date]))=MAX(T1[Date]),TRUE,FALSE)
But it only sets to true the one with date "06/08/2022 13:50".
Thank you in advance!!
Solved! Go to Solution.
Hi @Fátima
You can refer to the following example.
You can create a column:
isTheLatestOfId = var _filter=FILTER('Table',[C _ID]=EARLIER('Table'[C _ID]))
return if([DATE]=MAXX(_filter,[DATE]),TRUE(),FALSE())
Or you can create it as a measure:
Measure = var _filter=FILTER(ALL('Table'),[C _ID]=MAX('Table'[C _ID]))
return IF(MAX([DATE])=MAXX(_filter,[DATE]),TRUE(),FALSE())
Output:
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you @v-xinruzhu-msft and @olgad !
Since the answer by @v-xinruzhu-msft allows me to not create an additional column, I'll mark that one as the accepted solution.
Regards!
Hi @Fátima
You can refer to the following example.
You can create a column:
isTheLatestOfId = var _filter=FILTER('Table',[C _ID]=EARLIER('Table'[C _ID]))
return if([DATE]=MAXX(_filter,[DATE]),TRUE(),FALSE())
Or you can create it as a measure:
Measure = var _filter=FILTER(ALL('Table'),[C _ID]=MAX('Table'[C _ID]))
return IF(MAX([DATE])=MAXX(_filter,[DATE]),TRUE(),FALSE())
Output:
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Fatima,
not dax, but may be you can use it.
In Power query go transform group by
Hope that helps you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |