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
Anonymous
Not applicable

Making sense of a column containing day.hours:minutes:seconds

Hi there,

 

So I have two datetime columns and I have calculated the difference between them using:

each Duration.ToText([end date]-[start date]), type number)

 

I have a column with values such as 

78.08:11:05 = 78 days, 8 hours, 11 minutes, 5 seconds

00.00:54 = 0 days, 0 hours, 0 minutes, 54 seconds

 

As a number, this is throwing up an error when I close and apply as I guess DAX doesn't like the format. 

 

I am going to need to be able to translate this column into a turnaround measurement. 

 

Can you suggest anything to stop this erroring when I get to Report View, and also be able to sum this and have it recognised as a period of time?

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

I believe you should be using Power Query's Duration data type instead of number.

 

Here is something that I wrote recently for dealing with Durations in DAX:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639?search-a...

 

In DAX it is more of a formatting thing since it does not have a true duration data type.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

amitchandak
Super User
Super User

In case both are DateTime. You should be able to use datediff. And if you can give diff in the required unit.

 

https://docs.microsoft.com/en-us/dax/datediff-function-dax

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

In case both are DateTime. You should be able to use datediff. And if you can give diff in the required unit.

 

https://docs.microsoft.com/en-us/dax/datediff-function-dax

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Greg_Deckler
Super User
Super User

I believe you should be using Power Query's Duration data type instead of number.

 

Here is something that I wrote recently for dealing with Durations in DAX:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639?search-a...

 

In DAX it is more of a formatting thing since it does not have a true duration data type.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks both, these both work, I prefer the dax though. Not sure why I forgot about this! 

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.