remove all spaces from column headers in power query

mschoular

New Member
Joined
May 10, 2017
Messages
3
Hello. How would I remove all spaces from all column headers in power query with a large table? i.e "Part Number" needs to be "PartNumber"

I have succeeded using a small table with 10 columns and 10 rows by:
demoting headers
transposing the table
adding a custom column with Text.Remove([Column1]," ")
then transposing the table back and promoting headers with the new custom column names that have the spaces removed

My issue is that I have a table with 40+ columns and 165000 rows. the table is too large to transpose per the method above.

Any help would be appreciated. I am new to PQ
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Table.TransformColumnNames(Source, (columnName as text) as text => Text.Replace(columnName, " ", ""))
 
Upvote 0
Thank you. After a bit of messin' around, I was able to make the correct adjustments. It works perfectly!!!
 
Upvote 0
Table.TransformColumnNames(Source, (columnName as text) as text => Text.Replace(columnName, " ", ""))
This is wonderful and your work help me a lot but I have made some changes in you code like below

Table.TransformColumnNames(Source, (columnName as text) as text => Text.Trim(columnName))

This will not remove your genuine space between 2 words

Thanks Sir for your idea
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top