How to expand a date range into daily rows in Power BI

To show every day an event was active, generate a list of dates between its start and end in Power Query, then expand that list into rows. This solves a common calendar problem. A maintenance window that runs November 23–25 should appear on Tuesday the 24th too, even though the source records only Monday and Wednesday.

Build an event-by-day table

  1. In Power BI Desktop, choose Home → Transform data. In Power Query, right-click your events query and choose Reference. Name the new query EventDays. The original query stays at one row per event, which is useful for budgets or counts that belong to the event as a whole.
  2. Keep the event identifier and the two date columns. The example uses EventID, EventDate (the start), and EndDate. Set the two date columns to the Date data type. If your source contains timestamps, decide which local calendar dates they represent before dropping the time.
  3. Choose Add Column → Custom Column. Name it ActiveDate and enter the expression below. Substitute your own column names if they differ.
if [EventDate] = null or [EndDate] = null then
    {null}
else if [EndDate] < [EventDate] then
    {null}
else
    List.Dates(
        [EventDate],
        Duration.Days([EndDate] - [EventDate]) + 1,
        #duration(1, 0, 0, 0)
    )

List.Dates takes a starting date, a count, and a step. The difference between Monday and Wednesday is two days. Adding one generates three dates, including both endpoints. A one-day event generates one row. This example treats the recorded end date as the last active day. If your source stores the first inactive day instead, omit + 1 and keep only intervals whose end is later than their start.

  1. Select OK. Open the expand button in the ActiveDate column header and choose Expand to New Rows. Set the expanded column’s type to Date.
  2. Check rows with a blank ActiveDate. The formula leaves a blank when either endpoint is missing or the dates run backward. Correct the source, or filter blank dates out of EventDays before building a daily count. An open-ended assignment needs its own reporting cutoff.
  3. Select Home → Close & Apply. Build a table visual with ActiveDate and Distinct count of EventID. Use the date field itself for a row per day. A report with a separate calendar table can relate its unique date column to EventDays[ActiveDate] and use the calendar date in visuals.

Check an overlap before trusting the chart

Download the two-event CSV and open it with Get data → Text/CSV to try these exact rows. Event A runs November 23–25. Event B starts and ends November 24. The expanded query should have four rows. The daily visual should show these three results.

Active dateActive eventsDistinct count
November 23A1
November 24A, B2
November 25A1

Across all three dates the distinct event count is two. The four rows measure event-days. This distinction matters for amounts too. A $300 budget stored on Event A would appear three times if you carried it into the expanded rows. Sum budgets from the original event table, or define a daily allocation if that is what the report needs.

Microsoft documents the custom column editor, the List.Dates function, and what happens to the other columns when a list expands.

First published .