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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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,215,972
Messages
6,128,008
Members
449,414
Latest member
sameri

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