cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
poogleshmoogle
Frequent Visitor

calculate time between two columns and different rows - turnaround calculation

I have two columns:
In time and out time - the columns are formatted in date and time. I need to find the turnaround time in minutes (in time - previous out time). 

I also want the turnaround time for just the day, not between two dates. (on excel I was just doing less than 2 hours to be safe and then filtering) 

 

Another question based on the same data, so I would need to calculate the delay time(which is the first in time for the day - 8am), any idea on how to do that? For each day, have a new column that says the delay time.

 

Any help is appreciated! Thank you 

Screenshot (15).png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

The result is showing numbers in minute.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1669788997778.png

 

Turn Around CC =
VAR _currentdate =
    FORMAT ( Data[In Time], "yyyy-mm-dd" )
VAR _prevouttime =
    MAXX (
        FILTER (
            Data,
            FORMAT ( Data[In Time], "yyyy-mm-dd" )
                = FORMAT ( EARLIER ( Data[In Time] ), "yyyy-mm-dd" )
                && Data[Out Time] < EARLIER ( Data[Out Time] )
        ),
        Data[Out Time]
    )
VAR _result =
    DATEDIFF ( _prevouttime, Data[In Time], MINUTE )
RETURN
    IF ( NOT ISBLANK ( _prevouttime ), _result )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but I tried to create a sample pbix file like below.

The result is showing numbers in minute.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1669788997778.png

 

Turn Around CC =
VAR _currentdate =
    FORMAT ( Data[In Time], "yyyy-mm-dd" )
VAR _prevouttime =
    MAXX (
        FILTER (
            Data,
            FORMAT ( Data[In Time], "yyyy-mm-dd" )
                = FORMAT ( EARLIER ( Data[In Time] ), "yyyy-mm-dd" )
                && Data[Out Time] < EARLIER ( Data[Out Time] )
        ),
        Data[Out Time]
    )
VAR _result =
    DATEDIFF ( _prevouttime, Data[In Time], MINUTE )
RETURN
    IF ( NOT ISBLANK ( _prevouttime ), _result )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!

Top Solution Authors