Forum Discussion
Dicken
Post Prodigy
1 year agoPower Query conditional column selection
Hi , I wanted to select columns that contained a certain value and came up with this , but has anyone any ideas for a different approach ? here just selectign columns that contian "X". BTW, should...
- 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.
Dicken
Post Prodigy
1 year agoJust to add you can skip the List.AnyTrue which does give a flexible for All / Any ; but this also works;
= List.Transform( Table.ToColumns( Source ), (x)=>List.ContainsAny( x, {"X"}, (x,y)=>Text.Contains(x,y) ) )