Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
philongxpct
Frequent Visitor

Expand colum problem

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.

Spoiler
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?

1 ACCEPTED SOLUTION

Great, thanks you v-lvzhan-msft, not exact like i looking for but appriciated. I made a parameter ColsToKeep = Table.ToList(tbl1) from Table1 then try #"Expanded tbl2" = Table.ExpandTableColumn(PreviousStep, "tbl2", ColsToKeep, ColsToKeep) . Worked. Thanks again.

View solution in original post

3 REPLIES 3
Eric_Zhang
Microsoft Employee
Microsoft Employee

@philongxpct

If what you'd like is to select certain columns from one table based on the columns stored in another table, check 

 

let

    Source = Table.FromRows({{1,2,3,4,5},{1,2,3,4,5},{1,2,3,4,5}},{"col1","col2","col3","col4","col5"}),
    columnListTable = Table.FromRows({{"col1"},{"col2"},{"col3"}},{"column"}),
    
    selectedColumns = Table.SelectColumns(Source,Table.ToList(columnListTable ))
in
    selectedColumns

Great, thanks you v-lvzhan-msft, not exact like i looking for but appriciated. I made a parameter ColsToKeep = Table.ToList(tbl1) from Table1 then try #"Expanded tbl2" = Table.ExpandTableColumn(PreviousStep, "tbl2", ColsToKeep, ColsToKeep) . Worked. Thanks again.

@philongxpct

As your question is solved, if no further questions, you can accept your that reply as solution to close this thread. 🙂 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors