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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Date Difference

Hello, 

 

is it possible to subtract the 2 columns below and get the answer in a time format. 

 

Csmith31_0-1624569319007.png

 

The format that I am looking for would be 

7:14:41 or just 7:14

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

In the query editor, add your column where you subtract the two columns, which will result in a duration.  Change the type to a decimal number (that will be in days).  Load the data, then go to the Diagram View and use a custom format string to display it as a datetime with a format string of hh:nn:ss

 

mahoneypat_0-1624571491499.png

 

mahoneypat_1-1624571585840.png

 

 

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description and sample data, I can clearly understand your requirement, you can try this calculated column to output the duration time in the correct format:

Duration =

var _diff=[Date2]-[Date1]

return

HOUR(_diff)&":"&MINUTE(_diff)&":"&SECOND(_diff)

 

And you can get what you want, like this:

vrobertqmsft_0-1624872139870.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

In the query editor, add your column where you subtract the two columns, which will result in a duration.  Change the type to a decimal number (that will be in days).  Load the data, then go to the Diagram View and use a custom format string to display it as a datetime with a format string of hh:nn:ss

 

mahoneypat_0-1624571491499.png

 

mahoneypat_1-1624571585840.png

 

 

Pat

 

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors