#duration is a Power Query M function that creates a duration value from numbers representing days, hours, minutes, and (fractional) seconds.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
#duration(
days as number,
hours as number,
minutes as number,
seconds as number,
) as duration
Description
The #duration function creates a duration value based on the input numbers. It takes days, hours, minutes, and (fractional) seconds as input.
Examples
Let’s look at some examples.
You can return a duration of 5.10:30:59
, which represents 5 days, 10 hours, 30 minutes and 59 seconds as follows:
#duration ( 5, 10, 30, 59 )
You can easily transform a duration in a total number of seconds, minutes, hours or days.
Duration.TotalSeconds( #duration ( 5, 10, 30, 59 ) ) // returns 469859
Duration.TotalMinutes( #duration ( 5, 10, 30, 59 ) ) // returns 7830.9833333333336
Duration.TotalHours( #duration ( 5, 10, 30, 59 ) ) // returns 130.51638888888888
Duration.TotalDays( #duration ( 5, 10, 30, 59 ) ) // returns 5.43818287037037
Related functions
Other functions related to #duration are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy