Forum Discussion
How to batch multiple Renamed Column steps into one step
- 1 year ago
ArchStanton
Hi again
In answer to your question "My M code knowledge is very limited, can you provide an example of how this code will look"You can learn yourself.
Simply create some test data
Edit the query and overtype the columns.
The Power Query will automatically generate the the M rename code in the top window
If you click Advanced Editor then you can view the whole M script
This is how most developers learn M code,
by first using the wizard to crearte code
and then editing it.Learn more about Power Query for free here
https://www.youtube.com/watch?v=i66yyAl5_JcPlease click thumbs up and [accept solution] buttons.
Hi ArchStanton
It is best pratice to group Renames into a single step rather than have the steps spread over a Power Query
For example instaed of:-
- Add column 1
- Rename column 1
- Add column 2
- Rename column 2
- Add column 3
- Rename column 3
You could have :-
- Add column 1
- Add column 2
- Add column 3
- Rename column 1, 2 and 3
In your example, I suggest fisrt you back-up your work before making any changes.
Then delete the Renamed Columns, Renamed Columns1 and Renamed Columns2 steps
and add a new step that renames all three columns.
Unfortunately, if you have any references to the new name before new step then they will fail with name not found error, but you can easily edit these to the oldname. Then it work ok.
Please click thumbs up because I have tried to help.
Then click [accept solution] if it works.
Thank you
Hi, thanks for the reply.
My M code knowledge is very limited, can you provide an example of how this code will look using the 3 examples I've provided please?
Thanks