Forum Discussion
Convert Text Time Duration
- 2 years ago
Try reading through this chapter on all the duration functions: https://learn.microsoft.com/en-us/powerquery-m/duration-functions.
I think you'll want to convert to duration from text first. Then parse out your hours, minutes, seconds and either aggregate them separately or convert them all into the same unit and then aggregate.
Have you tried using the Duration functions in Power Query?
- mclawler2 years agoHelper III
I'm a rookie so bare with me 🙂 But I found the Duration Function within Power Query and it changed the data to a decimal number. You can see the comparison here between a converted column and a non-converted column. But what is this decimal telling me? A fraction/decimal of how many days/hours? If I know the basis of the decimal I think I can then convert to hours/minutes/seconds?
Thank you so much already!!
- CoreyP2 years agoSolution Sage
Try reading through this chapter on all the duration functions: https://learn.microsoft.com/en-us/powerquery-m/duration-functions.
I think you'll want to convert to duration from text first. Then parse out your hours, minutes, seconds and either aggregate them separately or convert them all into the same unit and then aggregate.
- mclawler2 years agoHelper III
That's perfect!! Thank you, I think you've got me on the right track now. Much appreciated!
- mclawler2 years agoHelper III
I think I found it
Even if I choose minutes though, and then it generates a decimal number. Is there an easy way to convert that decimal number to display in the visual card something like 8:35 for 8 hours and 35 minutes? It seems like this decimal is always going to give me a decimal type visual. Which would work, but cosmetically the 8:35 would look better than 8.5x hours if that makes sense...
- CoreyP2 years agoSolution Sage
Yeah, so you will need the data type to be in a number format so you can create your aggregation measures. But then you can do some calculations and dynamic format string to put it back into the HH:MM:SS text format you're looking for.