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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Unpivot table with dates

Hi All,

I qucikly drew in Excel what I need to achieve in Power Query

For now I have a table looking like that:

tomaszpatrzyk_0-1684494099612.png

My goal is to transform it to look like that:

tomaszpatrzyk_1-1684494170481.png

How to do it in Power Query?

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

hi, @Anonymous 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    types = Table.TransformColumnTypes(Source,{{"start_date", type date}, {"end_date", type date}}),
    comb_cols = Table.CombineColumns(types, {"start_date", "end_date"}, (x) => List.Dates(x{0}, Duration.Days(x{1} - x{0}) + 1, #duration(1, 0, 0, 0)), "dates"),
    ws = Table.AddColumn(comb_cols, "ws", each "Workshop"),
    expand = Table.ExpandListColumn(ws, "dates"),
    pivot = Table.Pivot(Table.TransformColumnTypes(expand, {{"dates", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(expand, {{"dates", type text}}, "en-US")[dates]), "dates", "ws")
in
    pivot

View solution in original post

1 REPLY 1
AlienSx
Super User
Super User

hi, @Anonymous 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    types = Table.TransformColumnTypes(Source,{{"start_date", type date}, {"end_date", type date}}),
    comb_cols = Table.CombineColumns(types, {"start_date", "end_date"}, (x) => List.Dates(x{0}, Duration.Days(x{1} - x{0}) + 1, #duration(1, 0, 0, 0)), "dates"),
    ws = Table.AddColumn(comb_cols, "ws", each "Workshop"),
    expand = Table.ExpandListColumn(ws, "dates"),
    pivot = Table.Pivot(Table.TransformColumnTypes(expand, {{"dates", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(expand, {{"dates", type text}}, "en-US")[dates]), "dates", "ws")
in
    pivot

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors