Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
4-3-3
Helper I
Helper I

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?

branchIDdateamountrecordedlatest
123415/10/201922015/10/2019 
123415/10/201922516/10/2019 
123415/10/201924517/10/2019yes
567815/10/201911515/10/2019 
567815/10/201913016/10/2019 
567815/10/201914217/10/2019yes
1 ACCEPTED SOLUTION

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())

1.PNG

 

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.

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.

View solution in original post

6 REPLIES 6
amitchandak
Super User
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.

Thanks for your input. Unfortunatetly that example only grouping by one column and I need this to look at two..

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())

7.PNG

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.

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.

Hi there, thanks for trying to help, it is much appreciated. Unfortunately this is not doing what I am after.

 

It measure needs to be looking on two columns - hence the question about using two columns in a group-by formula as that is how I interpret it in my head but it may not be the correct term..

 

Anyway,  I have prepared a better file that will hopefully be of a help to explain what I am after - i have added the 'latestFlag' column to mark the lines exactly how I need them to be.

 

https://radvisory-my.sharepoint.com/:x:/g/personal/tom_radvisory_co_nz/EY7ssyFpZEZDpbPIvQbWufcB1vFwS... 

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())

1.PNG

 

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.

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.

Beautiful! I did not realize that I can actually leave out the branchID from the measure all together as I can just use filter later on.

 

Thanks so much for helping!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.