Duration.From
DurationConverts a value to a duration.
Syntax
Duration.From(value as any) as nullable durationParameters
| Name | Type | Required | Description |
|---|---|---|---|
value | any | Yes | The value to convert. Accepts text, number, datetime, and datetimezone values. |
Return Value
duration — A 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 | |
|---|---|---|---|
| 1 | L002 | 1,725 | 1.04:45:00 |
| 2 | L004 | 2,745 | 1.21:45:00 |
| 3 | L006 | 1,065 | 0.17:45:00 |
| 4 | L008 | 2,670 | 1.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 | |
|---|---|---|
| 1 | 1.50 | 1.12:00:00 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks