Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Subtract Time based off of a variable

I'm really new to Power BI and was asked to create a report that shows the average drop off time at our warehouse. What is the best way to calculate the time difference based off of a variable in another column?

Essentially I need to take every UDC listed and see the time taken between the Pickup and Dropoff.

UDC_Pickup_Dropoff.jpg

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

you can try create a measure

 

 

Avg Time =
AVERAGEX (
    VALUES ( TableName[UDC] ),
    CALCULATE (
        DATEDIFF ( MIN ( TableName[TIME] ), MAX ( TableName[TIME] ), SECOND )
    )
)

 

 

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

you can try create a measure

 

 

Avg Time =
AVERAGEX (
    VALUES ( TableName[UDC] ),
    CALCULATE (
        DATEDIFF ( MIN ( TableName[TIME] ), MAX ( TableName[TIME] ), SECOND )
    )
)

 

 
Anonymous
Not applicable

Thanks for the reply @tamerj1 

I input the code into Power BI and it gives me a Avg time of zero. I do have a filter set up so that it can limit the results down to the last 7, 14, and 30 days.

This is the code that I have put in.

 
Avg Drop Off Time =
AVERAGEX (
VALUES ( LOG_USER_AUDIT[UDC] ),
CALCULATE (
DATEDIFF ( MIN ( LOG_USER_AUDIT[TIME] ), MAX ( LOG_USER_AUDIT[TIME] ), SECOND )
)
)
Anonymous
Not applicable

I actually had to create a new table. Once I moved the function over there it started to work.

Avg Drop Off Time In Seconds = 
AVERAGEX (
    VALUES ( 'IN THE LAST'[UDC] ),
    CALCULATE (
        DATEDIFF ( MIN ( 'IN THE LAST'[Time Format] ), MAX ( 'IN THE LAST'[Time Format] ), SECOND )
    )
)

 
Thanks for pointing me in the right direction.
UDC_Pickup_Dropoff.jpg

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)