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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Bernie6808
Frequent Visitor

Grouped By Query

I have a table of Academics working on projects within specific departments which I need to summarise by Subproject Data ID. Each project has a single 'Lead Subproject' and each Academic has a Credit %. Project and Subproject are concatenated to provide Subproject Data ID. The table is sorted Z-A on Lead_Subproject and Largest to Smallest on Credit.

Bernie6808_0-1671269151615.png

 

 

I have used 'Group by' to consolidate the data by Subproject_Data_ID, Project and Subproject, but I need to populate Lead_Subproject and Project_Lead with the first matching entries in the first table (which is why it is sorted): 

 

Bernie6808_1-1671269248956.png

 

At the moment I have to do this in Excel after loading the query using Xlookup/Index(Match()), but is there a way to do it within the Group By code? 

 

Best,

 

Bernie

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Bernie6808 ,
just apply a dummy-operation (like SUM or MAX) on those 2 columns and afterwards tweak the generated M-code a bit:
List.Sum or List.Max should become List.First instead.
Regarding the sorting, you might want to consider a Table.Buffer: 

https://community.powerbi.com/t5/Community-Blog/Bug-warning-for-Table-Sort-and-removing-duplicates-i...

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
Manoj_Nair
Solution Supplier
Solution Supplier

@Bernie6808 - not sure if you manage to achieve the desired output, but like to spin with an different way of approach. Try this and let me know if this fixes your issues. Give me a shout out if you need any more details PBIX File attached. Grouped by Query 

image.jpg

ImkeF
Community Champion
Community Champion

Hi @Bernie6808 ,
just apply a dummy-operation (like SUM or MAX) on those 2 columns and afterwards tweak the generated M-code a bit:
List.Sum or List.Max should become List.First instead.
Regarding the sorting, you might want to consider a Table.Buffer: 

https://community.powerbi.com/t5/Community-Blog/Bug-warning-for-Table-Sort-and-removing-duplicates-i...

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Perfect! Thanks!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors