Downloads
Power Query MDurationIntermediate

Duration.TotalHours

Returns the whole duration as a number of hours, including any part of an hour as a decimal.

Syntax
Duration.TotalHours(duration as nullable duration) as nullable number

Returns: The total hours as a number, or null when the input is null.

What it does

Duration.TotalHours returns the full length of a duration as hours, with fractions kept. A duration of two days and five and a half hours is 53.5 hours. It is the measure for a service level, such as a 48 hour approval target, because it counts all the time, not just the part after whole days.

Syntax and arguments

Example

A procurement policy says that purchase requests must be approved within 48 hours. The team measures the elapsed hours and flags any request that goes over the target.

let
    Requests = #table(type table [Request = text, Submitted = datetime, Approved = datetime],
        {{"PR-310", #datetime(2026, 10, 27, 9, 0, 0), #datetime(2026, 10, 29, 14, 30, 0)},
         {"PR-311", #datetime(2026, 10, 28, 16, 0, 0), #datetime(2026, 10, 29, 9, 0, 0)}}),
    Hours = Table.AddColumn(Requests, "HoursToApprove", each Duration.TotalHours([Approved] - [Submitted]), type number),
    Breach = Table.AddColumn(Hours, "OverTarget", each [HoursToApprove] > 48, type logical)
in
    Breach

PR-310 took 53.5 hours and is flagged as over the 48 hour target. PR-311 took 17 hours and is within the target. Using Duration.Hours instead would have shown only the part after whole days, which is wrong for this rule.

Example: a second, different use

Convert a one and a half day lead time into hours for a supplier scorecard that measures lead times in hours.

Things to watch

In business terms

Approval and response service levels, supplier lead times and close deadlines are set in hours. The total hours figure is the one that matches the policy, and it lets the controller show exactly which requests breached the target.

Related functions

All Power Query M functions · View as Markdown · M basics