cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PBI_newuser
Post Prodigy
Post Prodigy

Get the earliest/latest Date from column with possible repeated row value

Hi, I have a measure as below. How to get the earliest date for "Order Status-Closed" to calculate the hours difference?

For example, I want to take the date 31-Dec-20 7:12:00 PM as highlighted in yellow as Closed Date. Here is the pbix file.

PBI_newuser_0-1621930501622.png

 

Accepted to Closed = 
VAR a = data[ID]
VAR b =
MAXX (
FILTER(data, [ID] = a && [History New Value] = "Field Status - Accepted" ),
data[History CreatedDate]
)
VAR c =
MAXX (
FILTER ( data, [ID] = a && [History New Value] = "Order Status - Closed" ),
[History CreatedDate]
)

RETURN

IF(b<>BLANK()&&c<>BLANK(),
DIVIDE ( DATEDIFF ( b, c, SECOND ), 3600 ))
1 ACCEPTED SOLUTION
v-lionel-msft
Community Support
Community Support

Hi @PBI_newuser ,

 

Please refer to the .pbix file.

v-lionel-msft_0-1622095035461.png

 

Best regards,
Lionel Chen

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

2 REPLIES 2
v-lionel-msft
Community Support
Community Support

Hi @PBI_newuser ,

 

Please refer to the .pbix file.

v-lionel-msft_0-1622095035461.png

 

Best regards,
Lionel Chen

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

MintuBaruah
Helper II
Helper II

Hello @PBI_newuser 

 

To get the earliest/latest Date from a column you can use the following formula:

 

Measure = LASTNONBLANKVALUE('Table'[Date_Column], MAX('Table'[Date_Column]))

 

If you find the solution useful please mark my post as a solution!
In doing so, you are also helping me. Thank you!

Mintu Baruah

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

November Power BI Update 768x460.png

Check it Out!

Click here to read more about the November 2021 Updates!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.