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.
slorin
Super User
1 year agoHi Dicken
let
Source = YourSource,
DemoteHeaders = Table.DemoteHeaders(Source),
Transpose1 = Table.Transpose(DemoteHeaders),
SelectRows_with_X = Table.SelectRows(Transpose1, each not List.IsEmpty(List.FindText(List.Skip(Record.ToList(_)),"X"))),
Transpose2 = Table.Transpose(SelectRows_with_X),
PromoteHeaders = Table.PromoteHeaders(Transpose2, [PromoteAllScalars=true])
in
PromoteHeaders
Stéphane