Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
Anonymous
Not applicable

Unpivot data in Power Query based on Date range

Dear Experts,

In my table I have StartDate and EndDate column. 

Based on this, Each row will be created for this date range. 

Please see the input and output table.

 

Can you please help?

 

MohsinBipu_1-1723610021636.png

 

1 ACCEPTED SOLUTION
ahadkarimi
Solution Specialist
Solution Specialist

Hey @dufoq3, you’re right. The final version will be:

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

 

View solution in original post

4 REPLIES 4
Omid_Motamedise
Super User
Super User

Hi,

Try this formula

let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Start Date", type date}, {"End Date", type date}}),
#"Merged Columns" = Table.CombineColumns(#"Changed Type",{"Start Date", "End Date"},each (if _{1}=null then _{0} else List.Dates(_{0},Duration.Days(_{1}-_{0}),#duration(1, 0, 0, 0))),"Date"),
#"Expanded Date" = Table.ExpandListColumn(#"Merged Columns", "Date")
in
#"Expanded Date"


If my answer helped solve your issue, please consider marking it as the accepted solution.
ahadkarimi
Solution Specialist
Solution Specialist

@Anonymous, add a Custom Column with this formula and let me know if there is any problem:

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

Expand the new column to generate rows for each date.
Remove the original "Start date" and "End date" columns if not needed.

Hi, don't add +1 to Duration.Days --> based on example - he doesn't want to return dates till 14/08 but only to 13/08 for the first row.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

ahadkarimi
Solution Specialist
Solution Specialist

Hey @dufoq3, you’re right. The final version will be:

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

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.