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