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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Iterate thru table - Adding row to all rows in a table

For each row in this table i want to add a new row and just change "belop" to "- whatever "belop" and Kontoart to "1". 

I want to do this as a step in advanced editor.  Can anyone help me write the code? 

 

Shkr_0-1619422976731.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

You can try this query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR0VNJRMgViQwOlWJ1oJScnJyDHEoiNIALOzs5AjjEIQwRcXFyAHDMgNoEIuLq6AjnmIHOAArEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Kontoart = _t, Belop = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Kontoart", Int64.Type}, {"Belop", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Name"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns",each [Belop],each [Belop]*-1,Replacer.ReplaceValue,{"Belop"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",each [Kontoart],1,Replacer.ReplaceValue,{"Kontoart"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value1",{{"Belop", Int64.Type}}),
    #"Append table" = Table.Combine({#"Changed Type", #"Changed Type1"})
in
    #"Append table"

append.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
#"Table Repeat" = Table.Repeat(Table.TransformColumns(#"Added Index", {{"Beløp", each _ * -1, type number}}),2)
in
#"Table Repeat"

 

I tried this, but it applies to the whole table not just the copied one. 

Hi @Anonymous ,

You can try this query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnR0VNJRMgViQwOlWJ1oJScnJyDHEoiNIALOzs5AjjEIQwRcXFyAHDMgNoEIuLq6AjnmIHOAArEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Kontoart = _t, Belop = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Kontoart", Int64.Type}, {"Belop", Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Name"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns",each [Belop],each [Belop]*-1,Replacer.ReplaceValue,{"Belop"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value",each [Kontoart],1,Replacer.ReplaceValue,{"Kontoart"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Replaced Value1",{{"Belop", Int64.Type}}),
    #"Append table" = Table.Combine({#"Changed Type", #"Changed Type1"})
in
    #"Append table"

append.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

HotChilli
Super User
Super User

You can duplicate the table, add columns to replace the existing ones (not sure exactly what you want for belop , multiply by -1 maybe). Remove the old columns.

Then Append the new table and the original table together using the interface( from the ribbon->Home->Combine)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Top Solution Authors