Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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!
User | Count |
---|---|
128 | |
108 | |
99 | |
65 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |