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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Remove multiple columns in Power Query

Hi,

Is there a way to remove multiple columns in Power Query or do I need to remove one each time?

jarilomkm_0-1639756510378.png

 

Based on the above image, i'm checking if the column exists, and if it does, I want to remove it. What I want to do is to be able to remove multiple columns with e.g. "UnitPrice" and "TaxRate". I have also tried to add it outside of the Table.RemoveColumns function but it returns an error.

And a parameter just retuns one at a time so that doesn't seem efficient.

Do you have any working idea? I could merge the columns I want to remove but that's unnecessary processing, especially when it's 10+ columns.

Thankful for any help if it's possible!

Thank you and Merry Christmas!

Kind regards,

Jari

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You can intersect the list of columns you want to remove with the existing column names like this:

= Table.RemoveColumns(
    RenamedColumns,
    List.Intersect(
        {
            Table.ColumnNames(RenamedColumns),
            {"UnitPrice", "TaxRate"}
        }
    )
)

View solution in original post

7 REPLIES 7
wdx223_Daniel
Super User
Super User

NewStep = Table.RemoveColumns(PreviousStepName,{the list of column names which you want to remove},2)

Anonymous
Not applicable

Hi @Anonymous ,

 

Could you tell me if your problem has been solved by @AlexisOlson 's suggestion? If it is, kindly Accept it as the solution. More people will benefit from it.

 

Or you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Best Regards,
Eyelyn Qin

AlexisOlson
Super User
Super User

You can intersect the list of columns you want to remove with the existing column names like this:

= Table.RemoveColumns(
    RenamedColumns,
    List.Intersect(
        {
            Table.ColumnNames(RenamedColumns),
            {"UnitPrice", "TaxRate"}
        }
    )
)
Anonymous
Not applicable

Hi,

That works great, thanks!
But that comes with a follow-up question. Is it possible to make it dependent on a completely other table?
So to have a static table with multiple columns which is removing columns in the main table depending on the inputs in the static table?

Having a small table such as the following:

jarilomkm_0-1639987624430.png

 



/Jari

Sure. Use the column OtherTable[TestColumns] instead of Table.ColumnNames(...) in the code I suggested.

Anonymous
Not applicable

How would that syntax be written? I can't find out any "OtherTable"-function working there when I write it in the Advanced editor. I want to base it on a table named e.g. "Columns to be Removed" with a list of all the names that are the same as the columns i want removed in the main table. I can't find any similar syntax
Thanks!
Kind regards,

Jari

OtherTable isn't a function. It's what I used as a table name since I didn't know what the "completely other table" you mentioned was called.

 

That said, I may have misunderstood which list you wanted to replace. I think this modification may be what you're after:

 

= Table.RemoveColumns(
    RenamedColumns,
    List.Intersect(
        {
            Table.ColumnNames(RenamedColumns),
            #"Columns to be Removed"[TestColumns]
        }
    )
)

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.