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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
lava_
Helper I
Helper I

How to return value based on max date within a group

I created a table of three columns that are pulling from another table. I want this created table to ultimately be grouped by ID_1, and pull in the value from ID_2 column based on the group's max Closing Date. 

 

Below is an image of the table with duplicate values just so you can see what I'm working with.

 

lava__0-1681935173624.png

 

I'd like for the table to look like the below. As you can see in the image below, ID_2 is only pulling in values that match the max closing date in each group.

 

lava__3-1681935632839.png

 

For this table, I'm able to get as far as grouping ID_1 by the max Closing Date using the formula below. I've also been able to create a 1-to-many relationship between this created Table (1 side) and the DealsTable (many side) that it's pulling from. How can I adjust the formula below so I can also include values from the ID_2 column?  

 

Table = 
GROUP BY(
'DealsTable',
'DealsTable' [ID_1],
"Closing Date", MAXX(CURRENTGROUP(), 'DealsTable'[ClosingDate]))

 

lava__4-1681935846166.png

 

 

Thank you!

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @lava_ ,

 

Please try:

 

Table = FILTER('DealsTable',[ClosingDate]=CALCULATE(MAX('DealsTable'[ClosingDate]),FILTER('DealsTable',[ID_1]=EARLIER(DealsTable[ID_1]))))

 

Final output:

vjianbolimsft_0-1682041653359.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
v-jianboli-msft
Community Support
Community Support

Hi @lava_ ,

 

Please try:

 

Table = FILTER('DealsTable',[ClosingDate]=CALCULATE(MAX('DealsTable'[ClosingDate]),FILTER('DealsTable',[ID_1]=EARLIER(DealsTable[ID_1]))))

 

Final output:

vjianbolimsft_0-1682041653359.png

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

I used this approach, modifying the code to reflect the columns in my table, and it inexplicably just replicates another table in my report. 

What could be happening?

This worked! Thank you so much. 

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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