Forum Discussion
Power Query conditional column selection
- 1 year ago
Your table = Source.
You can use this anywhere you would normall use SelectColumns (or RemoveColumns)
= Table.SelectColumns(Source,List.Select(Table.ColumnNames(Source), each Text.Contains(_, "X", Comparer.OrdinalIgnoreCase)))I made the match case INsenistive, remove the Comparare.OrdinalIgnoreCase if you don't want that.
Your table = Source.
You can use this anywhere you would normall use SelectColumns (or RemoveColumns)
= Table.SelectColumns(Source,List.Select(Table.ColumnNames(Source), each Text.Contains(_, "X", Comparer.OrdinalIgnoreCase)))
I made the match case INsenistive, remove the Comparare.OrdinalIgnoreCase if you don't want that.
- Dicken1 year ago
Post Prodigy
Not sure it works, or Im missing something, I just got an empty 2 row table not the columns where and "X"is contained.
let
Source = let
Source = #table(
type table [A = text, B = text, C = text, D = text],
{{"a,b", "X,c", "c,c", "a,d"}, {"c,c", "a,a", "a,X", "d,c"}} ) in Source,
Custom1 = Table.SelectColumns(Source,List.Select(Table.ColumnNames(Source), each Text.Contains(_, "X", Comparer.OrdinalIgnoreCase)))
in
Custom1