Forum Discussion
Auto-rename all Query columns e.g. to remove underscore
Meanwhile the author of "Table.TransformColumnNames" (hint: me) is crying somewhere :'( I think it came out in July '15 update.
Nice code anyway :)
arify - I hadn't heard of that one and nothing like that came up after a lot of searching. Now you have named a specific function that sounds great but ... I just tried searching for "Table.TransformColumnNames" and I didnt get any relevant results (besides your mention on this thread). I can't see it listed in the MSDN PQ function doco either. Do you have any info you can share on it?
My 2c would be that developing code changes without any published mention or doco (including several practical examples) is basically pointless ...
- arify10 years agoMicrosoft Employee
Hi mike_honey,
We're still working on updating our documentation. Next time you needed a library function that doesn't appear in the documentation, try typing
= #shared
to the Power Query's formula bar like I suggested to greggyb. But 99% of the time, the function is already mentioned in a nicer way in the documentation, so that should be the first try.
About how to use it, there's some explanation and an example when you type
= Table.TransformColumnNames
to the PQ formula bar. In your case, it should probably look like this:
= Table.TransformColumnNames(table, (columnName as text) as text => Text.Replace(columnName, "_", ""))
- arify10 years agoMicrosoft Employee
It is up now, thanks everyone https://msdn.microsoft.com/en-us/library/mt674878.aspx
- mike_honey10 years agoMemorable Member
thanks arify - at least that function is exposed now. I found your last example in the thread above much more useful than the one posted in the documentation. That scenario (special characters in column headings) seems very unlikely.
Anyway I had to loop back to this to do something similar - inserting spaces for "Camel Case" column names e.g. CustomerName. So I have built a couple of examples using Table.TransformColumnNames and added it to my list of demo files (link below) for future reference - it's the one named:
Power Query demo - Renaming Columns automatically
- ks19 years agoFrequent Visitor
Hi What's the right syntax for replacing several text strings?
I tried:
= Table.TransformColumnNames(table, (columnName as text) as text => Text.Replace(columnName, {"_", ""}, {"other text", ""}))...but that didn't work
- mike_honey8 years agoMemorable Member
ks1 You've probably figured this out monts ago, but you would need to nest Text.Replace, e.g.
Text.Replace(Text.Replace(columnName, {"_", ""}), {"other text", ""})