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
navedkhan
Helper III
Helper III

HIGHLY URGENT - Calculate Time Stamp Difference

Hi Everyone - am facing hardships in calculating timestamp difference based on conditions. My data looks like below;

 

Capture.JPG

 

Now i want to see these as below;

 

1) Filter rows based on 'Earliest time and date' from a given workitem so that we get 1 row for 'Active' (earliest date and time) and 'Pending' (earliest date and time)

2) then calculate difference: Earliest Pending date & time - Earliest Active date & time

 

Is it possible to get this done in DAX?

 

@amitchandak @parry2k @Zubair_Muhammad @Felix 

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

Hi @navedkhan 

 

Kindly check my below results:

Measure = CALCULATE(MIN('Table'[Date&Time]),ALLEXCEPT('Table','Table'[Workitem no. ],'Table'[Status]))
Measure 2 = var a = MINX(FILTER(ALL('Table'),[Workitem no. ]=MAX('Table'[Workitem no. ])&&[Status]="Pending"),[Measure])
Return
ABS(DATEDIFF(a,[Measure],HOUR))

05.PNG

Pbix attached.

Community Support Team _ Dina Ye
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

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

If you question is still unanswered, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-diye-msft
Community Support
Community Support

Hi @navedkhan 

 

Kindly check my below results:

Measure = CALCULATE(MIN('Table'[Date&Time]),ALLEXCEPT('Table','Table'[Workitem no. ],'Table'[Status]))
Measure 2 = var a = MINX(FILTER(ALL('Table'),[Workitem no. ]=MAX('Table'[Workitem no. ])&&[Status]="Pending"),[Measure])
Return
ABS(DATEDIFF(a,[Measure],HOUR))

05.PNG

Pbix attached.

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
amitchandak
Super User
Super User

@navedkhan , Try like

if([Status] ="Pending"  ,maxx(filter(table,[workiten_no] =earlier([workiten_no])  && [Status] ="Active"),[Date & time])
minx(filter(table,[workiten_no] =earlier([workiten_no])  && [Status] ="Pending"),[Date & time]),blank())

could you pls help suggest with a workable solution? Am waiting to put it into production.

No it doesn't work as expected. it gives me wrong date&time values.

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.