Mearns Learns

Table Mountain built with blocks

Expand date ranges into a full list of dates

If you have a range of dates, with start and end dates for specific periods, you can easily expand to date ranges for a full list of dates. So instead of having a date range of 17-Sep to 16-Jan, you can get each day in the range; 17-Sep, 18-Sep, … , 15-Jan, 16-Jan.
No missing dates, so long as the date ranges are continuous.

This makes it possible to join dates in other tables to the expanded date range table.

Starting with date ranges like this that represent stages.

Start DateEnd DateStage
17/09/202116/01/20221st Stage
17/01/202216/06/20222nd Stage
17/06/202216/09/20223rd Stage
17/09/202216/01/20231st Stage
17/01/202316/06/20232nd Stage
17/06/202316/09/20233rd Stage
17/09/202316/01/20241st Stage

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

Select the table of dates and navigate the Data menu tab and click on From Table/Range.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

The data will be imported into Power Query.
Change the format of the date columns to Date.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

Navigate to the Add Column menu tab and click on the Custom Column icon. Add a formula to create a list of dates based on the Start Date and End Date of each row.

List.Dates([Start Date],Duration.Days( [End Date] - [Start Date] ) + 1,  #duration( 1, 0, 0, 0 ))

Breaking down the formula, List.Dates(start as date, count as number, step as duration) as list, the start is set as the Start Date.
The count uses Duration.Days to calculate the number of days between the Start Date and the End Date and adds one day.
The #duration is set to 1 day, 0 hours, 0 minutes, 0 seconds.
This creates a list of dates from the Start Date to the End Date.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

A list will be added to each row.
Click on the Expand icon in the column heading.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

The date ranges will be expanded into a full list of dates.
Remove the columns that you no longer need.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates

Navigate to the Home menu tab and click on the Close & Load icon.
The data will be loaded back into Excel.
The data can be used to join tables.
For example it can be merged with other queries to bring in other data, in this case, the Stage.

Expand date ranges into a full list of dates Expand date ranges into a full list of dates