Duration.TotalSeconds

Duration

Returns the total number of seconds represented by a duration value.

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

Syntax

Duration.TotalSeconds(duration as nullable duration) as nullable number

Parameters

NameTypeRequiredDescription
durationdurationYesThe duration value to convert to total seconds.

Return Value

numberThe total number of seconds as a number.

Remarks

Duration.TotalSeconds returns the total elapsed time of a duration value expressed as a number of seconds. Unlike Duration.Seconds, which returns only the seconds component (0 through 59), Duration.TotalSeconds converts the entire duration to seconds. If the input is null, the function returns null.

Examples

Example 1: Convert DurationMinutes to total seconds

Table.AddColumn(
    Table.SelectColumns(
        Table.SelectRows(
            OrderLog,
            each [DurationMinutes] <> null
        ),
        {"LogID", "DurationMinutes"}
    ),
    "TotalSeconds",
    each Duration.TotalSeconds(#duration(0, 0, [DurationMinutes], 0)),
    type number
)
Result
LogID
DurationMinutes
TotalSeconds
1L0021,725103,500
2L0042,745164,700
3L0061,06563,900
4L0082,670160,200

Example 2: Total seconds from a scalar duration

#table(
    type table [Duration = duration, TotalSeconds = number],
    {{#duration(0, 2, 30, 15), Duration.TotalSeconds(#duration(0, 2, 30, 15))}}
)
Result
Duration
TotalSeconds
10.02:30:159,015

Compatibility

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