Duration.ToText

Duration

Converts a duration value to its text representation.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Duration.ToText(duration as nullable duration) as nullable text

Parameters

NameTypeRequiredDescription
durationdurationYesThe duration value to convert to text.

Return Value

textA text string in the format "D.HH:MM:SS" representing the duration, or null if the input is null.

Remarks

Duration.ToText formats a duration value as a text string using the format "D.HH:MM:SS" (days, hours, minutes, seconds). Durations shorter than one day omit the day prefix (e.g., "02:30:00"). Fractional seconds are included when present. This function is the inverse of Duration.FromText and produces the canonical M duration text representation.

If the input is null, the function returns null. The output format is not localized — it always uses . as the day separator and : between time components, regardless of the host culture. This makes it safe for serialization, logging, and round-tripping through Duration.FromText.

Note that the output format (D.HH:MM:SS) is not the same as ISO 8601 duration format (PTxHxMxS). If you need ISO 8601 output, you will need to construct it manually using Duration.Days, Duration.Hours, Duration.Minutes, and Duration.Seconds.

Examples

Example 1: Display duration values as text for a report

Table.AddColumn(
    Table.SelectColumns(
        Table.SelectRows(OrderLog, each [DurationMinutes] <> null),
        {"LogID", "DurationMinutes"}
    ),
    "DurationText",
    each Duration.ToText(#duration(0, 0, [DurationMinutes], 0)),
    type text
)
Result
LogID
DurationMinutes
DurationText
1L0021,7251.04:45:00
2L0042,7451.21:45:00
3L0061,0650.17:45:00
4L0082,6701.20:30:00

Example 2: Convert a specific duration to text

#table(
    type table [Duration = duration, AsText = text],
    {{#duration(3, 5, 30, 0), Duration.ToText(#duration(3, 5, 30, 0))}}
)
Result
Duration
AsText
13.05:30:003.05:30:00

Example 3: Round-trip a duration through text and back

let
    Original = #duration(1, 4, 45, 0),
    AsText = Duration.ToText(Original),
    BackToDuration = Duration.FromText(AsText)
in
    #table(
        type table [Original = duration, AsText = text, Recovered = duration],
        {{Original, AsText, BackToDuration}}
    )
Applied Steps

The final output — a one-row table showing the original duration, its text form, and the recovered duration after round-tripping through text.

Original
AsText
Recovered
11.04:45:001.04:45:001.04:45:00

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks