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

Return Max Date of Grouped ID Filtered by Value in Another Column

Hi, folks,

 

First of all, this forum is amazing.

 

I want to create the "Max Date by Value" column, which includes the largest date for each ID group that has the value of 2.

 

Here is what I want such a table to look like.

 

IDDateValueMax Date by Value
111/1/201545/1/2013
15/1/201455/1/2013
15/1/201325/1/2013
211/1/20121Null
31/1/201321/1/2016
36/1/201051/1/2016
311/1/201641/1/2016
31/1/201621/1/2016
37/1/201771/1/2016

 

Here is the code I am playing with that is not working:

Max Term 2 Date =
var a =CALCULATE(MAX('Table'[Date]),ALLEXCEPT('Table', 'Table'[ID]), FILTER('Table', 'Table'[Value]=2))
var b =CALCULATE(MAX('Table'[Date]), FILTER('Table', 'Table'[ID]=EARLIER('Table'[ID])),'Table'[Date]=a)
Return
b
 
Thoughts on how to proceed?
 
Thanks!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Try

Column

Max Date by Value = if([Value]=2, blank(),maxx(filter('Table', [ID]=earlier([ID])),[Date]))

 

Measure

Max Date by Value = calculate(max(Date),ALLEXCEPT('Table', 'Table'[ID]),[Value]<>2)
Max Date by Value = if(max([Value]=2),blank(),calculate(max(Date),ALLEXCEPT('Table', 'Table'[ID])))

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

Try

Column

Max Date by Value = if([Value]=2, blank(),maxx(filter('Table', [ID]=earlier([ID])),[Date]))

 

Measure

Max Date by Value = calculate(max(Date),ALLEXCEPT('Table', 'Table'[ID]),[Value]<>2)
Max Date by Value = if(max([Value]=2),blank(),calculate(max(Date),ALLEXCEPT('Table', 'Table'[ID])))

Anonymous
Not applicable

Thank you, @amitchandak!

Anonymous
Not applicable

I think I just figured it out.

 

CALCULATE(MAX('Table'[Date]), FILTER('Table', 'Table'[ID]=EARLIER('Table'[ID])),'Table'[Value]=2)
 
I was overthinking it, but there may be a better way.

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.