Duration.From

Duration

Converts a value to a duration.

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

Syntax

Duration.From(value as any) as nullable duration

Parameters

NameTypeRequiredDescription
valueanyYesThe value to convert. Accepts text, number, datetime, and datetimezone values.

Return Value

durationA duration value converted from the given input.

Remarks

Duration.From converts text or number values into a duration. Number values are interpreted as days (e.g., 1.5 represents 1 day and 12 hours). Text values must be in the format d.hh:mm:ss. If the input is null, the function returns null.

Examples

Example 1: Convert DurationMinutes to duration

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

Example 2: Convert a number to a duration

#table(
    type table [Days = number, Duration = duration],
    {{1.5, Duration.From(1.5)}}
)
Result
Days
Duration
11.501.12:00:00

Compatibility

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