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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Grouping table rows based on max values

Hi there!

 

Each row in my table (named Documents) represents a document created by a user of my application. Whenever a user edits a document, it creates a new version of the document.  Each document has what is called a GroupKey. The GroupKey is the unique identified for each document. Any groupkey can have many versions. 

 

As a results, my table contains each version of every document ever created in the app. I am intersted in reporting on only the latest version of any given document.  so, I need to figure out a way to create a new table that ony has the max version number of each GroupKey.

 

Here is a snapshot of the table I am working with:

table.png

 

I would appreciate any advice on how to acheive this. My instincts are telling me I need to group by the max value of the Version column for every GroupKey, but do not know how to acheive this. 

 

Thank you!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

Create a calculated column like this and this will flag the latest version in each group key and then you can filter on this flag column to get the latest version only.

 

Flag= IF(CALCULATE(MAX(Table1[Version]),FILTER(Table1,Table1[GroupKey]=EARLIER(Table1[GroupKey])))=Table1[Version],1,0)

 

Thanks
Raj

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi

Create a calculated column like this and this will flag the latest version in each group key and then you can filter on this flag column to get the latest version only.

 

Flag= IF(CALCULATE(MAX(Table1[Version]),FILTER(Table1,Table1[GroupKey]=EARLIER(Table1[GroupKey])))=Table1[Version],1,0)

 

Thanks
Raj

Anonymous
Not applicable

This solution worked well, thank you! 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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