Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
Hi,
I need to keep the first and last columns of multiple sheets I'm pulling in from Excel.
They vary in number of columns and I'm utilising the same Power Query to transform them.
If I use the "Remove Other Columns" wizard it hardcodes the column numbers which means when I use it for the next sheet it is trying to keep a non-existant column.
Is there anyway of saying in PQ to keep the first an alst column without referencing the column numbers?
Thanks.
Solved! Go to Solution.
Sure:
KeepColumns = {List.First(Table.ColumnNames(Name_of_your_previous_step)),List.Last(Table.ColumnNames(Name_of_your_previous_step))},
#"Removed Other Columns" = Table.SelectColumns(Name_of_your_previous_step,KeepColumns)
Sure:
KeepColumns = {List.First(Table.ColumnNames(Name_of_your_previous_step)),List.Last(Table.ColumnNames(Name_of_your_previous_step))},
#"Removed Other Columns" = Table.SelectColumns(Name_of_your_previous_step,KeepColumns)
Thanks for that Marcel
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 79 | |
| 48 | |
| 35 | |
| 31 | |
| 27 |