Duration.ToText is a Power Query M function that converts duration values into a readable textual representation, adopting the pattern “day.hour:mins:sec”.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Duration.ToText(
duration as nullable duration,
optional format as nullable text,
) as nullable text
Description
The Duration.ToText function converts a duration value into a text string in the format “day.hour:min:sec”. The optional format argument is deprecated and will cause an error if used.
Examples
To understand the utility of the Duration.ToText function, let’s look at a couple of practical examples.
Consider you have a duration value of #duration( 1, 4, 29, 08 )
. Here’s how you can transform it into a text value:
Duration.ToText( #duration( 1, 4, 29, 08 ) ) // Output: "1.04:29:08"
What’s more, the function doesn’t discriminate based on the size of the duration value. It can work its charm on larger duration values too. For instance:
Duration.ToText( #duration( 111, 10, 0, 59 ) ) // Output: "111.10:00:59"
As seen above, the Duration.ToText function successfully converts a longer duration of 111 days, 10 hours, 0 minutes, and 59 seconds into a neat text format.
And that’s all there is to turning a duration into text so you can easily incorporate it in a bigger string.
Related functions
Other functions related to Duration.ToText are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy