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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Only group by max of column in query editor

HI all

 

I am trying to get the data in Power query to which adres of a customer we have done the most deliveries. 

My dat a look as follows

NameAdresclassnumber of delvieries
JaneabcroadHouse43
JaneDBCRoadappartment1
JoeBVSavenueuHouse2
JoeBFQstreetGetto50

 

I would like the output tabel in the query editor  to be like this:

NameadressclasNumber of delveriies
Jane abcroadHouse 43
JoeBFQstreetGetto50

 

Could you help me

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the Group function and Table.Max() function to meet your requirement.

 

1. Group the name column, and group all rows.

 

only1.jpg

 

2. Then add a custom column and expand it.

 

only2.jpg

 

only3.jpg

 

3. At last, delete the Details column.

 

only4.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

View solution in original post

4 REPLIES 4
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

 

If you've fixed the issue on your own please kindly share your solution.

If the above posts help, please kindly mark it as a solution to help others find it more quickly. Thanks a lot.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use the Group function and Table.Max() function to meet your requirement.

 

1. Group the name column, and group all rows.

 

only1.jpg

 

2. Then add a custom column and expand it.

 

only2.jpg

 

only3.jpg

 

3. At last, delete the Details column.

 

only4.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

Anonymous
Not applicable

@Anonymous 

Based on your example I added the following steps to see the two customers with the most deliveries: 

#"Sorted Rows" = Table.Sort(#"Changed Type",{{"number of delvieries", Order.Descending}}), // Changed Type was last step in PQ 
#"Kept First Rows" = Table.FirstN(#"Sorted Rows",2)
in
#"Kept First Rows"

 

Hope this helps. 

amitchandak
Super User
Super User

@Anonymous , In Dax you can have two new measures for last twp columns. Other two you can dag as is

 

new class =
VAR __id = MAX ( 'Table'[Name] )
VAR __date = CALCULATE ( MAX( 'Table'[number of delvieries] ), ALLSELECTED ( 'Table' ), 'Table'[Name] = __id )
CALCULATE ( Max ( 'Table'[class] ), VALUES ( 'Table'[Name ), 'Table'[Name] = __id, 'Table'[number of delvieries] = __date )

 

 

new number of delvieries =
VAR __id = MAX ( 'Table'[Name] )
VAR __date = CALCULATE ( MAX( 'Table'[number of delvieries] ), ALLSELECTED ( 'Table' ), 'Table'[Name] = __id )
CALCULATE ( Max ( 'Table'[number of delvieries] ), VALUES ( 'Table'[Name ), 'Table'[Name] = __id, 'Table'[number of delvieries] = __date )

 

 

Power Query

https://www.excelguru.ca/blog/2016/05/25/keep-the-most-recent-entry/

https://exceleratorbi.com.au/remove-duplicates-keep-last-record-power-query/

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.