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
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.

MintuBaruah
Helper III
Helper III

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
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.