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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
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