Home > Enterprise >  How to unpivot date range in Excel/ PowerQuery
How to unpivot date range in Excel/ PowerQuery

Time:12-04

Would someone be able to tell me the best way of unpivoting the date range that currently appears in each row: start date and end date, so that the 'Title' appears row by row for each date included in the date range.

I expect the title not to appear once, but line by line as many times as the date range indicates - so if the date range runs from 01/12/2022 to 03/12/2022 the Title will appear three times with the calendar date in the column next to it: 01/12/2022, 02/12/2022, 03/12/2022.

Image of the dataset:

My current thinking is to use PowerQuery but I'm stuck. Maybe there's a clever Excel function that can do what I need. Any suggestion/ help would be awesome. Many thanks!

CodePudding user response:

The trick is to read the two dates as numbers.

  1. Read the start and end dates as numbers Int64.Type
  2. Make a new column and create a list/range with {[Date start]..[Date end]}
  3. Expand the list to multiple rows with enter image description here

  • Related