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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
KJChin
Frequent Visitor

Choose Column before Expand Table

I am importing data from multiple excel files in sharepoint folder to Power Query. I would like to define the chosen columns before expand the data. Previously I have defined to take the data of first sheet of every excel file in the folder as the sheet name is not constant (it works). Same reason with the columns, the name sometimes changes, while the order is remain same. 

This is the query I done in 'Transform Sample File':

let
    Source = Excel.Workbook(Parameter1, null, true),
    FirstSheet = Source{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(FirstSheet, [PromoteAllScalars=true])
in
    #"Promoted Headers"

 

Below is the enhance version to cover the column, get error where it said:
Expression.Error: We cannot convert the value 1 to type Text.
Details:
Value=1
Type=[Type]

let

    Source = Excel.Workbook(Parameter1, null, true),
    FirstSheet = Source{0}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(FirstSheet, [PromoteAllScalars=true]),
    SelectedColumns = Table.SelectColumns(PromotedHeaders, {1, 2, 3, 7})

in
    SelectedColumns

  I did set the data type yet the error still there.

 

Any suggestions is much appreciated. Thank you.

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi @KJChin 

 

...
Table.SelectColumns(PromotedHeaders, List.Transform({1, 2, 3, 7}, each Table.ColumnNames(PromotedHeaders){_ - 1}))

 Stéphane

View solution in original post

2 REPLIES 2
slorin
Super User
Super User

Hi @KJChin 

 

...
Table.SelectColumns(PromotedHeaders, List.Transform({1, 2, 3, 7}, each Table.ColumnNames(PromotedHeaders){_ - 1}))

 Stéphane

KJChin
Frequent Visitor

OMG, IT WORKED! HAHA

Thanks a lot, @slorin You are amazing!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors