Dynamic Cols select

philongxpct

New member
Joined
Mar 14, 2017
Messages
3
Reaction score
0
Points
0
I working on a project that have multi columns data from multi excel files. User must declare what columns to keep from sample fisrt N rows of data and don't care about headers, just column1, column2....Im did a table contain rows of value like 4,5,15,20...and try this code, but i dont know how to do it right.
let
Cols = Table2, \\Contain rows of colums to keep
Colnums = Table.ToList (Table2),
Source = Table1 \\Mass data table ~50 cols
#"Expanded" = Table.ExpandTableColumn(Source, "Table1", each List.Select(Colnums))
in
#"Expanded"
this is my result:.........references other queries or steps, so it may not directly access a data source....How i do it right?
 
View attachment DynamicColsSelect.xlsx I built 2 small sample tables, Table2 has just one column, listing the names of columns to be displayed in Query1, the columns of which come from Table1.
Is this what you are looking for?


Code:
let
    Colnums = Table.ToList(Table2),
    Expanded = Table.SelectColumns(Table1,Colnums)
in
    Expanded
 
Back
Top