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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

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.