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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

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

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.