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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Rygar
Helper II
Helper II

Transform Table with FROM TO Date into multiple line/dates Table

Dear Community,

 

can anyone help me, with the transformation below?

I Think it should be possible without programming a loop...

Here is an Example file

 

Many thanks an regards,

Michael

 

Example_From_To_Date.png

 

1 ACCEPTED SOLUTION
ronrsnfld
Super User
Super User

  • This can all be done from the GUI
  • Create  a custom column with the date lists and give it a name of "Date"
    • List.Dates([From],Duration.Days([To]-[From])+1,#duration(1,0,0,0))

ronrsnfld_0-1637454078606.png

 

  • Delete the From/To Columns
  • Move the new Date column to the proper location
  • Expand the Date column into Rows (click on the two headed arrow at the top of the column and you will see that as an option)

 

M Code from Advanced Editor

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"ProductFamily", type text}, {"From", type date}, {"To", type date}, {"ID", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", 
        each List.Dates([From],Duration.Days([To]-[From])+1,#duration(1,0,0,0))),
    
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"From", "To"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"ProductFamily", "Date", "ID"}),
   #"Expanded Date" = Table.ExpandListColumn(#"Reordered Columns", "Date"),
   #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
    #"Changed Type1"

 

 

ronrsnfld_1-1637454267265.png

 

 

 

View solution in original post

2 REPLIES 2
ronrsnfld
Super User
Super User

  • This can all be done from the GUI
  • Create  a custom column with the date lists and give it a name of "Date"
    • List.Dates([From],Duration.Days([To]-[From])+1,#duration(1,0,0,0))

ronrsnfld_0-1637454078606.png

 

  • Delete the From/To Columns
  • Move the new Date column to the proper location
  • Expand the Date column into Rows (click on the two headed arrow at the top of the column and you will see that as an option)

 

M Code from Advanced Editor

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{
        {"ProductFamily", type text}, {"From", type date}, {"To", type date}, {"ID", type text}}),
    
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", 
        each List.Dates([From],Duration.Days([To]-[From])+1,#duration(1,0,0,0))),
    
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"From", "To"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"ProductFamily", "Date", "ID"}),
   #"Expanded Date" = Table.ExpandListColumn(#"Reordered Columns", "Date"),
   #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}})
in
    #"Changed Type1"

 

 

ronrsnfld_1-1637454267265.png

 

 

 

Really cool and so easy! Thank you very much!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.