Replacing _ with a space in table column names

OK, I have column names in a Data Warehouse as data source, which do not have spaces in.
i.e.
First_Name
Last_Name
Some_Date
Some_Other_Date
Amount_Number_One_But_Before_Two
Amount
This data is pulled into Power Query where I would like to replace the _ with a space.
i.e.
First Name
Last Name
Some Date
Some Other Date
Amount Number One But Before Two
Instead of manually changing, is there another way?, say M Code to do this?.
The code should work for not just the example above but for any data pull in future.
There could be more columns than the example above, and the column names will have varying number of _ to replace.

Hope that makes sense and is possible.

Many Thanks,

1 Like

Before

image

After

= Table.TransformColumnNames (Source, each Replacer.ReplaceText(_, "_", " "))

image

Replace Unscore From Column Headers.pbix (18.2 KB)

4 Likes

This can also be created as a function, apply it to your table schema and it will update all of your tables in one go.

Hello @marcster_uk

Good to see that you are having progress with your inquiry. Did the responses from @DavieJoe help you solve your inquiry?

If it does, kindly mark his answer as the Solution to your query.

If not, how far did you get and what kind of help do you need further?

Yey, thanks @DavieJoe :slight_smile:

1 Like

Anytime!