Forum Discussion
Remove all columns since one specific column
- 6 years ago
Hello twister8889
was this stated in your first post? No.
Please always state what exactly you need
this code should fit your second requirement
let Source = #table ( {"Country","Place","Zip","New Columns 1","State"}, { {"A","43466","","",""} } ), ColumnName = "New Column", DeleteColumns = if List.IsEmpty(List.Select(List.Transform(Table.ColumnNames(Source), each Text.Contains(_, ColumnName)) ,each _ = true)) then Source else Table.RemoveColumns(Source, List.Difference(Table.ColumnNames(Source), List.FirstN(Table.ColumnNames(Source), each not(Text.Contains(_, ColumnName))) )) in DeleteColumnsCopy 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 twister8889
was this stated in your first post? No.
Please always state what exactly you need
this code should fit your second requirement
let
Source = #table
(
{"Country","Place","Zip","New Columns 1","State"},
{
{"A","43466","","",""}
}
),
ColumnName = "New Column",
DeleteColumns = if List.IsEmpty(List.Select(List.Transform(Table.ColumnNames(Source), each Text.Contains(_, ColumnName)) ,each _ = true)) then Source else
Table.RemoveColumns(Source, List.Difference(Table.ColumnNames(Source), List.FirstN(Table.ColumnNames(Source), each not(Text.Contains(_, ColumnName))) ))
in
DeleteColumns
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
I'm so sorry, my fault
Thank you so much.