Reply
Bernie6808
Frequent Visitor
Partially syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

@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

Syndicated - Outbound

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

Syndicated - Outbound

Perfect! Thanks!

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)