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

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

Reply
bhmiller89
Helper V
Helper V

DATEDIFF Using Time

I have two columns: "Open Date/Time" and "Resolved Date/Time." They are both Date/Time data types

 

Not every item has a resolved date/time, but all of them have open date/time.

 

I need to calculation the total time in hours between "Open Date/Time" and "Resolved Date/Time."

 

I'm not able to get it to work using DATEDIFF

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

Minutes = 
SWITCH (
    TRUE (),
    'Table'[start_date] < 'Table'[end_date], DATEDIFF ( 'Table'[start_date], 'Table'[end_date], MINUTE ),
    'Table'[start_date] > 'Table'[end_date], DATEDIFF ( 'Table'[end_date], 'Table'[start_date], MINUTE ) * -1,
    0
)

This will take care of start times that are after end times which cause an error

Also as you can see blanks would not cause errors and how you hanlde those is up to you Smiley Happy

DATEDIFF - Minutes.png

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

Minutes = 
SWITCH (
    TRUE (),
    'Table'[start_date] < 'Table'[end_date], DATEDIFF ( 'Table'[start_date], 'Table'[end_date], MINUTE ),
    'Table'[start_date] > 'Table'[end_date], DATEDIFF ( 'Table'[end_date], 'Table'[start_date], MINUTE ) * -1,
    0
)

This will take care of start times that are after end times which cause an error

Also as you can see blanks would not cause errors and how you hanlde those is up to you Smiley Happy

DATEDIFF - Minutes.png

dedelman_clng
Community Champion
Community Champion

Are you getting a specific error message when creating the column/measure, or just not seeing the data you are expecting?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.