Forum Discussion
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?
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"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.
3 Replies
- HotChilliCommunity Champion
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)
- AnonymousNot 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.
- v-yingjlCommunity Support
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"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.