Forum Discussion
How do you GROUPBY two collumns with DAX?
I have a table that has multiple records for each day of the year for multiple entities. I need to create a column that will flag the newest record for each day as per the below example. Can someone please help me to achieve this with DAX?
| branchID | date | amount | recorded | latest |
| 1234 | 15/10/2019 | 220 | 15/10/2019 | |
| 1234 | 15/10/2019 | 225 | 16/10/2019 | |
| 1234 | 15/10/2019 | 245 | 17/10/2019 | yes |
| 5678 | 15/10/2019 | 115 | 15/10/2019 | |
| 5678 | 15/10/2019 | 130 | 16/10/2019 | |
| 5678 | 15/10/2019 | 142 | 17/10/2019 | yes |
Hi 4-3-3 ,
I modified my formula that you can have a try.
Flag = var max_recorded = CALCULATE(MAX('Table'[recorded]),ALLEXCEPT('Table','Table'[date])) return IF('Table'[recorded] = max_recorded,"Yes",BLANK())Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
6 Replies
- amitchandak
Super User
Please check, if this example can help
https://community.powerbi.com/t5/Desktop/Most-Recent-Record/td-p/675012
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.- 4-3-3
Helper I
Thanks for your input. Unfortunatetly that example only grouping by one column and I need this to look at two..
- v-xuding-msft
Community Support
Hi 4-3-3 ,
I created a measure that may help you.
Measure = var max_recorded = CALCULATE(MAX('Table'[recorded]),ALLEXCEPT('Table','Table'[branchID])) return IF(MAX('Table'[recorded]) = max_recorded,"Yes",BLANK())Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.