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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.