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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Beck
New Member

[Power Query] Get max value of rows with grouping.

I am trying  to group data set to reflect the Max of the Total column.

 

I have this data set

DateProductIDPriceOrdersTotal
1-Jana1211111
1-Jana1312336
1-Jana1312224
2-Jana1211444
2-Jana1211222
2-Jana1211555

 

I want to get it grouped by Date and ProductID and reflect Max on this date for ProductID

DateProductIDPriceOrdersTotalMax
1-Jana121111111
1-Jana131233636
2-Jana121155555
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Beck ,

 

You can use the group by feature:

 

danextian_2-1718947374135.png

 

Here's a sample code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtT1SsxT0lFKNDQCkoaGIALCiNVBljUGCYKUgBjGZrhkwdgELGuEabIJCOOUBes1wiVrCsKmSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, ProductID = _t, Price = _t, Orders = _t, Total = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"ProductID", type text}, {"Price", Int64.Type}, {"Orders", Int64.Type}, {"Total", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "ProductID", "Price"}, {{"Orders", each List.Max([Orders]), type nullable number}, {"Total", each List.Max([Total]), type nullable number}})
in
    #"Grouped Rows"

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Beck ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

danextian
Super User
Super User

Hi @Beck ,

 

You can use the group by feature:

 

danextian_2-1718947374135.png

 

Here's a sample code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtT1SsxT0lFKNDQCkoaGIALCiNVBljUGCYKUgBjGZrhkwdgELGuEabIJCOOUBes1wiVrCsKmSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, ProductID = _t, Price = _t, Orders = _t, Total = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"ProductID", type text}, {"Price", Int64.Type}, {"Orders", Int64.Type}, {"Total", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "ProductID", "Price"}, {{"Orders", each List.Max([Orders]), type nullable number}, {"Total", each List.Max([Total]), type nullable number}})
in
    #"Grouped Rows"

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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