Skip to content

Filling in dates

Sometimes a report gives only a start date and an end date, or a start date and a number of days, but the analysis needs a row for every date in between.

Each scenario on this page solves this the same way. A custom column builds a list of dates for each row with List.Dates, and expanding that list then gives one row per date.

Here, each person has a start date, an end date and a number of hours per day:

An Excel table with Person, Start Date, End Date and Hours per Day for four people

To fill in the dates between each person’s start and end date:

  • Load the table into Power Query.
  • On the Add Column tab, click Custom Column, name the column Dates, and enter the formula below.

The Custom Column dialog creating Dates with List.Dates, starting at Start Date and counting Duration.Days of End Date less Start Date, plus 1

The formula counts the days from start to end, adding 1 so that the end date is included, and asks for that many dates at one-day steps from the start date. Each row of the new column holds a list:

The query with a Dates column holding a List on each row

Next, click the expand button in the Dates column’s header and choose Expand to New Rows:

The expand menu on the Dates column, with Expand to New Rows highlighted

Each person now has one row for each date from their start date to their end date:

The expanded table, with a row for each person and each date between their start and end dates

Scenario 2: a number of days from a start date

Section titled “Scenario 2: a number of days from a start date”

In this table, each person has a membership start date and the number of days the membership lasts:

An Excel table with Person, Start Date and Membership Valid for, in days

To expand each membership into its dates:

  • Load the table into Power Query.
  • Add a custom column called Dates with the formula below.

The Custom Column dialog creating Dates with List.Dates, starting at Start Date and counting Membership Valid for

Here the number of days is already in the table, so the formula passes it straight to List.Dates. Each row again holds a list:

The query with a Dates column holding a List on each row

After the Dates column is expanded to new rows, each membership has one row per day:

The expanded table, with four rows for a four-day membership, five for a five-day membership and so on

This table holds a first appointment for each patient, the number of follow-up appointments needed and the number of days between them. The task is to work out when the follow-ups fall.

An Excel table with Initial Appointment, Patient, Follow ups needed and Frequency

To work out the follow-up dates:

  • Load the table into Power Query.
  • Add a custom column called Follow Up Dates with the formula below.

The Custom Column dialog creating Follow Up Dates with List.Dates, starting at Date.AddDays of the initial appointment and the frequency, counting Follow ups needed, at steps of Duration.From of the frequency

The list starts one interval after the first appointment, holds as many dates as there are follow-ups, and steps by the interval, which Duration.From turns from a number of days into a duration. Each row holds a list:

The query with a Follow Up Dates column holding a List on each row

After the Follow Up Dates column is expanded to new rows, each follow-up appointment has a row of its own with its date:

The expanded table, where a first appointment on 11/07/2020 with two follow-ups every five days gives 16/07/2020 and 21/07/2020