Forum Discussion
Moving values from columns
- 5 years ago
Hello brunofds
add a new column where you are generating your new table. Then delete all other columns and expand the new columns
here the formula
[FirstColumn = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [A] else [B], SecondColumns = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [B] else [C]]here the complete code
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVJNT8JAFPwrLz1BrNBSMHBsAE/4kcKNcHi0D7JJu9vsLsSfo/FA8O4v6B9ztyBRATWgt9d0dt68mRmPnRE+ICQEYZIxzpSWWKyKZwGJgHBOXBNcM448JiYFxGIqMUGgDLyg7jXqDa/hOa4TtH3X88FMfJGmzsT9K95aJ2i6QecTczm4TgUuoNqVxTphWthNXUvCixVatLcHvcc5ZmZxic1RxpSigkvzjBtxWiijIoOItJBcHKYIcyE1KRhSLEmjZEdW9Wgp0sX23iPLbu3PiCibilQVT0tiao9sGA56d9C/gcCve35pisX47WYz+IgblGeXxykoHmHnykF1EfHEiLHZ5CmLbS6v5qhdHFuh35r5WyfsLrZxPaIclUKTf06pgJHIzCz/18DTgvfbV63WiVX7GkWvWE8PJXEk2pO4znH6zDL83LyKeV81XxGpOeoyAATjO1czksULj011UEAv7PdB0qwGJi4talaR7dVsIy5+V7DhnbwB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]), #"Added Custom" = Table.AddColumn(Source, "CreateNewTable", each [FirstColumn = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [A] else [B], SecondColumns = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [B] else [C]]), #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"CreateNewTable"}), #"Expanded CreateNewTable" = Table.ExpandRecordColumn(#"Removed Other Columns", "CreateNewTable", {"FirstColumn", "SecondColumns"}, {"FirstColumn", "SecondColumns"}) in #"Expanded CreateNewTable"output is this
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello brunofds
add a new column where you are generating your new table. Then delete all other columns and expand the new columns
here the formula
[FirstColumn = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [A] else [B],
SecondColumns = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [B] else [C]]
here the complete code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVJNT8JAFPwrLz1BrNBSMHBsAE/4kcKNcHi0D7JJu9vsLsSfo/FA8O4v6B9ztyBRATWgt9d0dt68mRmPnRE+ICQEYZIxzpSWWKyKZwGJgHBOXBNcM448JiYFxGIqMUGgDLyg7jXqDa/hOa4TtH3X88FMfJGmzsT9K95aJ2i6QecTczm4TgUuoNqVxTphWthNXUvCixVatLcHvcc5ZmZxic1RxpSigkvzjBtxWiijIoOItJBcHKYIcyE1KRhSLEmjZEdW9Wgp0sX23iPLbu3PiCibilQVT0tiao9sGA56d9C/gcCve35pisX47WYz+IgblGeXxykoHmHnykF1EfHEiLHZ5CmLbS6v5qhdHFuh35r5WyfsLrZxPaIclUKTf06pgJHIzCz/18DTgvfbV63WiVX7GkWvWE8PJXEk2pO4znH6zDL83LyKeV81XxGpOeoyAATjO1czksULj011UEAv7PdB0qwGJi4talaR7dVsIy5+V7DhnbwB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t, C = _t]),
#"Added Custom" = Table.AddColumn(Source, "CreateNewTable", each [FirstColumn = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [A] else [B],
SecondColumns = if Text.StartsWith([A],"Taxa de Administração do Agente Financeiro cobrada em") then [B] else [C]]),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"CreateNewTable"}),
#"Expanded CreateNewTable" = Table.ExpandRecordColumn(#"Removed Other Columns", "CreateNewTable", {"FirstColumn", "SecondColumns"}, {"FirstColumn", "SecondColumns"})
in
#"Expanded CreateNewTable"
output is this
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
After some adjustments, that solution worked
Thank you 🙂