Power Query Duration.TotalMinutes: How to Use It
In this article
Duration.TotalMinutes converts a duration value into a decimal number of minutes. It takes one argument — a duration — and returns the total minutes as a number, including any fractional part. For example, Duration.TotalMinutes(#duration(1, 2, 30, 0)) returns 1590, because 1 day 2 hours 30 minutes equals 26.5 hours, which is 1590 minutes. If you have a column of durations (say, call lengths or machine run times) and you need a numeric column for math, sorting, or charting, this is the function to use.
What You'll Need
- Power BI Desktop or Excel with Power Query (the function is identical in both).
- A query with a column whose values are of type Duration, or a way to create duration values (for example from subtracting two datetime columns).
- Basic familiarity with the Power Query Editor: the formula bar, the Add Column tab, and the Advanced Editor.
Step-by-Step
- Confirm your column is a Duration. In the Power Query Editor, look at the small icon to the left of the column header. A duration column shows a clock-like icon, and the values look like
1.02:30:00. If the column is Text or a number,Duration.TotalMinuteswill fail. Select the column, then use the data type dropdown in the Home tab (or right-click the header) and choose Duration. If the values are text like "02:30:00", change the type to Duration first; Power Query parses that pattern automatically. - Create a new custom column. On the Add Column tab, click Custom Column. Give it a name such as "Total Minutes".
- Enter the formula. In the Custom Column dialog, type
Duration.TotalMinutes([YourDurationColumn]), replacingYourDurationColumnwith the exact name of your duration column (case-sensitive, no quotes unless the name contains spaces — in which case use[#"Column Name"]). Click OK. - Set the new column's type. The custom column comes in as
any. Click the data type icon in the new column header and choose Decimal Number (or Whole Number if you want to round). This matters: leaving it asanycan cause errors later in visuals and relationships. - Verify a value by hand. Pick one row and check the math. A duration of
0.02:30:00(2 hours 30 minutes) should give 150. If you see 2.5, you have usedDuration.TotalHoursby mistake; if you see 9000, you have usedDuration.TotalSeconds. - Apply and close. Click Close & Apply to load the result. The new numeric column is now available for aggregation, sorting, and conditional logic.
- (Optional) Do it in one M step. If you prefer editing the query directly, open the Advanced Editor and add a step such as
AddedMinutes = Table.AddColumn(PreviousStep, "Total Minutes", each Duration.TotalMinutes([Duration]), type number). This is the same operation the Custom Column dialog generates.
Common Mistakes
- Passing text or a time value.
Duration.TotalMinutesexpects a duration, not atimeor a text string. Atimevalue like 02:30:00 has no date component and will raise an error. Convert withDuration.From([Time])first, or build the duration from datetimes. - Expecting a formatted result. The function returns a plain number, not "2h 30m". If you want a display string, format it afterwards in the report layer or concatenate with
Number.Roundand text functions. - Forgetting the column reference brackets. Writing
Duration.TotalMinutes(MyColumn)without[ ]produces an error or an unexpected value. - Leaving the result as
any. This is the most common cause of "the column won't sum" or "the visual shows a count instead of a sum". Always set the type explicitly. - Confusing TotalMinutes with Minutes.
Duration.Minutesreturns only the minute component (0–59) of the duration, whileDuration.TotalMinutesreturns the whole duration expressed in minutes. For 1.02:30:00,Duration.Minutesgives 30 andDuration.TotalMinutesgives 1590. - Nulls in the source. A null duration passed to the function returns null, which can silently break averages. Filter or replace nulls before converting.
Tips
- Use
Number.Round(Duration.TotalMinutes([Duration]), 1)if you want one decimal place for reporting. - To get whole minutes rounded down, wrap with
Number.IntegerDivideorNumber.RoundDown. - If your source stores elapsed time as text in the format
hh:mm:ss, change the type to Duration before applying the function; Power Query recognises that pattern. For text like "2h 30m", you will need to parse it withDuration.FromTextafter normalising the string. - Keep the original duration column. It is useful for display ("02:30:00") while the numeric column is useful for math. You can hide the numeric column from the report view if needed.
- When subtracting two datetime columns, the result is already a duration, so you can go straight to
Duration.TotalMinutes([End] - [Start])without an intermediate step.
Troubleshooting
If the Custom Column dialog rejects your formula, check three things in order: the column name is spelled exactly as in the header, the column is genuinely of type Duration, and the function name is capitalised as Duration.TotalMinutes (M is case-sensitive for identifiers).
If the step runs but every value shows Error, click the error cell to read the message. "We cannot convert the value ... to type Duration" means the source column is text or a number; retype it first. "The field 'X' of the record wasn't found" means the column name in brackets does not exist — rename or re-select it from the Available Columns list.
If the numbers look wrong by a factor of 60, you have used the wrong unit function. TotalMinutes is minutes; TotalHours is hours; TotalSeconds is seconds. Swap accordingly.
If the column will not aggregate in a visual, confirm its type is Decimal Number or Whole Number, not any. If the query refreshes slowly, the duration conversion is not usually the cause — check upstream steps and data source performance.
If values are null, inspect the source rows; null durations propagate as null. Use Table.SelectRows to filter them out or Table.ReplaceValue to substitute zero, depending on what the report needs.
Frequently Asked Questions
What does Duration.TotalMinutes return for 1 day?
1440. One day is 24 hours, and 24 × 60 = 1440 minutes. The function always returns the full duration converted to minutes, including any fractional part.
Can I use Duration.TotalMinutes on a time column?
Not directly. A time value is not a duration. Wrap it: Duration.TotalMinutes(Duration.From([TimeColumn])), or convert the time to a duration first in a separate step.
How is it different from Duration.Minutes?
Duration.Minutes returns only the minute component (0 to 59) of the duration. Duration.TotalMinutes returns the entire duration expressed in minutes. Use TotalMinutes when you need a single numeric measure.
Does it work in Excel Power Query as well as Power BI?
Yes. The M engine and the function behave the same in Excel's Get & Transform and in Power BI Desktop. Menu labels can differ slightly by version, but the formula is identical.
Why does my result show as a whole number when the duration has seconds?
The column type is probably set to Whole Number, which rounds. Change it to Decimal Number to keep the fractional minutes.
Can I convert the result back to a duration?
Yes. Use #duration(0, 0, [TotalMinutes], 0) to rebuild a duration from a number of minutes, or Duration.From([TotalMinutes] / 1440) for days.