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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
cottrera
Post Prodigy
Post Prodigy

Power Query - Duplicate rows and add additional columns

Hi 

 

I have a table with one row per address

Address & Income Table 
Property ReferenceAddressIncome
1234100 Dax Street£3,000
5678303 Calculate Road£4,000
91011123 Evaluate Street£2,500

 

 

I would like to use power query to duplicate each of these rows multiple times but also add some additional columns (shown below) On the actual report I would like 30 rows adding per property but for this dummy example I am just show you 6 rows

 

In addition to this request I would like the first date to have the current year and all remaining dates there after to change based on the first date

Columns to add 
DateOrderDiscount Rate
01/01/202110.037
01/01/202220.037
01/01/202330.037
01/01/202440.037
01/01/202550.037
01/01/202660.027

 

The reason for this request is for my companies 30 year plan , which I will be adding Net Present Value (NPV)

 

My expected outcome based on my example table would be ,

 

Desired Outcome
Property ReferenceAddressIncomeindexDate
1234100 Dax Street£3,000101/01/2021
1234100 Dax Street£3,000201/01/2022
1234100 Dax Street£3,000301/01/2023
1234100 Dax Street£3,000401/01/2024
1234100 Dax Street£3,000501/01/2025
1234100 Dax Street£3,000601/01/2026
5678303 Calculate Road£4,000101/01/2021
5678303 Calculate Road£4,000201/01/2022
5678303 Calculate Road£4,000301/01/2023
5678303 Calculate Road£4,000401/01/2024
5678303 Calculate Road£4,000501/01/2025
5678303 Calculate Road£4,000601/01/2026
91011123 Evaluate Street£2,500101/01/2021
91011123 Evaluate Street£2,500201/01/2022
91011123 Evaluate Street£2,500301/01/2023
91011123 Evaluate Street£2,500401/01/2024
91011123 Evaluate Street£2,500501/01/2025
91011123 Evaluate Street£2,500601/01/2026

 Thank you

 

Richard

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @cottrera 

 

You said 30 rows, the sample was 6 rows. And I am not sure if you have that table contains Date, Order, Discount Rate, so I am doing it with 6 rows and no other table. If you need 30 rows, change Counter =30

Vera_33_0-1626748050019.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlHSUTI0MFBwSaxQCC4pSk0tAQocWmysY2BgoBSrE61kamZuARQyNjBWcE7MSS7NSSxJVQjKT0wBqzOBq7M0NDA0BBlmZKzgWpaYUwpSh2SikY4pSGUsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Property Reference" = _t, Address = _t, Income = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Property Reference", Int64.Type}, {"Address", type text}, {"Income", Currency.Type}}),
    Counter=6,
    initialList = {0..Counter-1},
    startYear = Date.Year( DateTime.LocalNow()),
    YearList = List.Transform(initialList, each _ +startYear),
    #"Converted to Table" = Table.FromList(YearList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Date", each #date([Column1],1,1)),
    #"Added Index" = Table.AddIndexColumn(#"Added Custom", "Index", 1, 1, Int64.Type),
    #"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Column1"}),
    Custom1 = Table.AddColumn(#"Changed Type", "new",each #"Removed Columns"),
    #"Expanded new" = Table.ExpandTableColumn(Custom1, "new", {"Date", "Index"}, {"Date", "Index"})
in
    #"Expanded new"

 

View solution in original post

2 REPLIES 2
cottrera
Post Prodigy
Post Prodigy

Thank you Vera_33 your M-Code worked on my demo table. I will attempt to edit it so that it works on my acutual live table  

 

regards

Richard

Anonymous
Not applicable

Hi @cottrera 

 

You said 30 rows, the sample was 6 rows. And I am not sure if you have that table contains Date, Order, Discount Rate, so I am doing it with 6 rows and no other table. If you need 30 rows, change Counter =30

Vera_33_0-1626748050019.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlHSUTI0MFBwSaxQCC4pSk0tAQocWmysY2BgoBSrE61kamZuARQyNjBWcE7MSS7NSSxJVQjKT0wBqzOBq7M0NDA0BBlmZKzgWpaYUwpSh2SikY4pSGUsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Property Reference" = _t, Address = _t, Income = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Property Reference", Int64.Type}, {"Address", type text}, {"Income", Currency.Type}}),
    Counter=6,
    initialList = {0..Counter-1},
    startYear = Date.Year( DateTime.LocalNow()),
    YearList = List.Transform(initialList, each _ +startYear),
    #"Converted to Table" = Table.FromList(YearList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Date", each #date([Column1],1,1)),
    #"Added Index" = Table.AddIndexColumn(#"Added Custom", "Index", 1, 1, Int64.Type),
    #"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Column1"}),
    Custom1 = Table.AddColumn(#"Changed Type", "new",each #"Removed Columns"),
    #"Expanded new" = Table.ExpandTableColumn(Custom1, "new", {"Date", "Index"}, {"Date", "Index"})
in
    #"Expanded new"

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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