Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Helper I
Helper I

Trim transformation for list of columns



I'd like to execute the Trim transformation in Power Query for a set of columns in my table.

I can do that if I select manually by clicking on the columns one-by-one and once it's done I can do the transformation. However, I'd need to select loads of columns with similar names, so I'd rather give the list of these columns and execute the transformation for each.


This is the current syntax:
= Table.TransformColumns(
     PreviousStep, {
         { "Column1", Text.Trim, type text},
          "Column2", Text.Trim, type text},
          "Column5", Text.Trim, type text},
          "Column15", Text.Trim, type text},

Can we have something similar like this instead:
     PreviousStep, {
           {"Column1", "Column2", "Column5", "Column15"}, Text.Trim, type text })

Thanks in advance!

Community Support
Community Support

Hi @PDG_VL ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.

Best Regards

Super User
Super User

Something like this?


    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclRQUNJRUnBSgNDOIDo2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
    #"Changed Columns" = Table.TransformColumns(#"Changed Type",{},Text.Trim)
    #"Changed Columns"

Thanks for the answer. It does this for all the columns in the previous steps, however, is there a way to select a list of columns and all (so let's say you have Column1, Column2, Column3 and only want to do this for Column1and2)?

So you called my bluff. Fair enough.


If this is important to you please consider raising it at

Helpful resources

PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors