Forum Discussion
MMoll
3 years agoFrequent Visitor
Need help iterating over all columns
I have columns constaining a mix of records and lists. I need to convert them all to lists, collapse them into a table, and then expand them. (Thus extracting the contents of each list without disrup...
MMoll
3 years agoFrequent Visitor
Yes; that's exactly what I'm trying to do. But I need the list of columns (and/or column names) to be dynamic so I can set it up as a function.
ThxAlot
3 years agoSuper User
let
fx_TableTransfermation = (t as table) =>
let
#"Combined Columns" = Table.CombineColumns(
t,
Table.ColumnNames(t), each Table.FromColumns(List.Transform(_, each if Value.Is(_, type list) then _ else {_})),
"Combined"),
#"Expanded Combined" = Table.ExpandTableColumn(#"Combined Columns", "Combined", List.Transform({1..Table.ColumnCount(t)}, each "Column"&Text.From(_)))
in
#"Expanded Combined",
Source = Table.FromColumns({{null,"ac",{1..3}},{{"A".."D"},123,""},{1,{"u".."z"}}}),
Invocation = fx_TableTransfermation(Source)
in
Invocation