Duration.Minutes is a Power Query M function that extracts the minutes portion of a duration value. The function returns an integer representing the number of minutes.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Duration.Minutes( duration as nullable duration ) as nullable number
Description
The Duration.Minutes function extracts the minutes portion (0-59) from a duration.
Examples
Let’s see how we can use the Duration.Minutes
function.
Duration.Minutes to Calculate Duration in Minutes
The Duration.Minutes
function extracts the number of minutes from a duration value. For example, a duration of 25 minutes returns 25 minutes:
Duration.Minutes( #duration( 0, 0, 25, 0 ) ) // Output: 25
Notice that when the duration value spans over a day, the Duration.Minutes function only extracts the number of remaining minutes after subtracting any full hour in the duration value.
Duration.Minutes( #duration( 0, 1, 30, 0 ) ) // Output: 30
The output is the same when the duration value specifies 90 minutes directly:
Duration.Minutes( #duration( 0, 0, 90, 0 ) ) // Output: 30
Creating a Time List
The Duration.Minutes
function is particularly useful when generating a time list. Suppose you want to create a list of times every minute starting from 12:00 PM and ending at 12:04 PM on the same day. You can use the following code:
List.Times(
#time(12, 0, 0),
Duration.Minutes( #time( 12, 4, 0 ) - #time( 12, 0, 0 ) ) + 1,
#duration( 0, 0, 1, 0 )
)
- List.Times: Generates a list of times.
- Start Time:
#time(12, 0, 0)
specifies the starting time (12:00 PM). - Number of Minutes:
Duration.Minutes(#time(12, 4, 0) - #time(12, 0, 0)) + 1
calculates the number of minutes between the start and end times. Adding 1 ensures the list includes both the start and end times. - Increment:
#duration(0, 0, 1, 0)
specifies the interval between each time in the list (one minute in this case).
By using Duration.Minutes
, you can easily compute the number of minutes between two times and generate a complete list of times for any given range.
Related functions
Other functions related to Duration.Minutes are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy