Power Query List.Times: Step-by-Step Guide
In this article
List.Times creates a list of time values starting at a given time, incrementing by a duration you specify, and repeating a set number of times. It is the time-only sibling of List.Dates and List.DateTimes, and it is the quickest way to build a column of clock times in Power Query, whether you need hourly slots, half-hour appointment blocks, or a simple 24-hour reference list. You do not need any add-in: List.Times is a built-in M function available in Power Query in Excel and Power BI Desktop.
What You'll Need
- Power Query Editor open, either from Excel (Data > Get Data) or Power BI Desktop (Transform data).
- A query to work in, or a blank query you can create from Home > New Source > Blank Query.
- Basic familiarity with the formula bar and the M language, since List.Times is written as a function call, not a button.
Step-by-Step
- Open the Power Query Editor. In Excel, select any cell in your data and go to Data > Get Data > Launch Power Query Editor. In Power BI Desktop, click Transform data on the Home ribbon. Menu labels can vary slightly by version and platform, but the editor itself works the same way in both.
- Create a blank query. Go to Home > New Source > Blank Query. A new query appears in the Queries pane on the left, and the formula bar shows a single step.
- Open the Advanced Editor if you prefer to write the whole expression. Go to Home > Advanced Editor. This is optional: you can also type directly into the formula bar. The Advanced Editor is useful because it shows the full M script and lets you paste a complete List.Times expression in one go.
- Write the function call. The syntax is
List.Times(start as time, count as number, step as duration). For example, to build 24 hourly times starting at midnight, enter:= List.Times(#time(0,0,0), 24, #duration(0,1,0,0))
The first argument is the starting time, the second is how many values to produce, and the third is the gap between each value expressed as a duration. - Understand the duration arguments.
#duration(days, hours, minutes, seconds)takes four numbers. For hourly steps use#duration(0,1,0,0); for 30-minute steps use#duration(0,0,30,0); for 15-minute steps use#duration(0,0,15,0). The first number is days, so a step of one day would be#duration(1,0,0,0), though for date-level work List.Dates is usually the better choice. - Convert the list to a table. A bare list is not very useful in a report. With the query selected, go to Transform > To Table. In the dialog, leave the defaults (no delimiter) and click OK. You now have a single-column table where each row holds one time value.
- Set the column type. Click the type icon in the column header and choose Time. Power Query may have inferred it already, but setting it explicitly prevents later steps from treating the values as text or numbers.
- Rename the column. Double-click the column header and give it a meaningful name such as Slot Time or Start Time.
- Load the result. Go to Home > Close & Load (Excel) or Home > Close & Apply (Power BI). The table of times is now available to your workbook or data model.
- Combine with other data if needed. If you want a full date-and-time column, merge this time column with a date column using Transform > Merge Columns, or build the whole thing at once with List.DateTimes, which takes a datetime start, a count, and a duration step.
Common Mistakes
- Passing a date instead of a time. List.Times expects a time value such as
#time(9,0,0). If you pass a date or a datetime, the function errors. Use List.Dates or List.DateTimes for those types. - Forgetting the count argument. The second argument is mandatory. A call with only a start time and a step will not run.
- Mixing up the duration order.
#durationis days, hours, minutes, seconds, in that order. Writing#duration(1,0,0,0)when you meant one hour gives a one-day step, which is easy to miss because the list still generates. - Off-by-one counts. List.Times returns exactly the number of values you request, starting with the start time. If you want times from 00:00 up to but not including 24:00, a count of 24 is correct; asking for 25 adds a value past midnight, which wraps to 00:00 and looks like a duplicate.
- Leaving the column as Any type. If you skip the type step, later merges and comparisons can behave unpredictably. Always set the column to Time.
- Expecting a table directly. List.Times returns a list. You must convert it with To Table before loading it as a query result.
Tips
- Use the formula bar for quick edits and the Advanced Editor when you want to see or paste the full script.
- Name your steps in the Applied Steps pane so you can find the List.Times call later; right-click a step and choose Rename.
- If you need the same time list in several queries, create it once as a separate query and reference it from the others rather than duplicating the expression.
- For a list that ends at a specific time rather than a fixed count, calculate the count first: for example, the number of minutes between start and end divided by your step size, rounded up.
- List.Times works well as a lookup table for time-slot reporting. Load it once and relate it to your fact table on the time column.
Troubleshooting
If the function returns an error, check the argument types first: a time, a number, and a duration, in that order. A common cause is a start value that Power Query reads as text, which happens when you type a time without the #time constructor. If the list generates but the values look wrong, inspect the duration arguments one by one; a misplaced number shifts the whole sequence. If To Table produces unexpected columns, make sure you selected the list query itself and not a step inside another query. If the column will not convert to Time, look for nulls or text values introduced by a later step and remove them before changing the type. When an error message points to a specific step, click that step in Applied Steps and read the formula bar to see exactly what was passed. If the query is slow, check whether the list is very large; thousands of time values are fine, but millions will slow the editor, and a different approach such as generating times in the source system may be better.
Frequently Asked Questions
What is the difference between List.Times and List.DateTimes?
List.Times produces time-only values, List.DateTimes produces datetime values, and List.Dates produces date-only values. Choose the one that matches the column type you need.
Can I use List.Times with a step of one second?
Yes. Use #duration(0,0,0,1) for a one-second step. Keep the count reasonable, because a full day at one-second intervals is 86,400 rows.
Does List.Times work in both Excel and Power BI?
Yes. It is part of the M language used by Power Query in Excel, Power BI Desktop, and other Microsoft products that host Power Query. The editor layout differs slightly, but the function call is the same.
Why does my list show duplicate times?
Most often the count is one too high, so the sequence wraps past midnight and repeats the start time. Reduce the count by one or check your start time.
Can I generate only working hours?
Not directly with List.Times, because it produces a continuous sequence. Generate the full list and then filter the rows to the hours you want, or build separate lists for each block and combine them.
How do I turn the list into a column with a custom format?
After converting to a table, use Transform > Format > Trim or a custom column with Time.ToText to control how the times display.