on 09-27-2016 08:29 AM - edited on 07-27-2021 11:36 PM by APIUserOpsDM
This article is part of the Tool Mastery Series, a compilation of Knowledge Base contributions to introduce diverse working examples for Designer Tools. Here we’ll delve into uses of the Dynamic Rename Tool on our way to mastering the Alteryx Designer:
The Dynamic Rename Tool is part of the developer category of tools. It allows the user to quickly rename any or all fields within an input stream by employing the use of different methods.
The user has the option to rename only certain fields, all fields, or even dynamic/unknown fields at runtime (e.g. after a Cross Tab Tool).The option for renaming fields are:
Renaming using Formula
This is useful if there is a pattern to the fields you want to rename, e.g. if you want to remove a prefix or suffix or want to replace underscores with spaces.
In this example, the Cross Tab Tool replaced spaces with underscores and added the prefix "Sum_" to all store types. Using the formulareplacechar(regex_replace([_CurrentField_],"Sum_",""),"_"," ") in the Dynamic Rename Tool removes "Sum_" and the underscores:
The Dynamic Rename Tool will also pick up new headers so you don't have to worry about checking for new store types.
Take Field Names from First Row of Data
Often, the field names aren't the header row in your file, they are in a subsequent row. In that case, you can use the option "Take Field Names from First Row of Data". This option discards the headers and replaces them with the first row of data. What if your field names are in the 3rd row of data? You can use the Sample Tool to skip the first two rows of data and then use the Dynamic Rename Tool to get the headers from what used to be the 3rd row of data.
Take Field Names from Right Input Metadata
If you have two files with the same layout, one with headers and one without, you can use the metadata from the file with headers and apply it to the file without headers. You can even apply field types and sizes. This option requires the tool to have the right input.
NOTE: The order of fields has to be the same in both files as it renames by position.
Take Field Names from Right Input Rows
Select this option if you have been provided with a file without headers and a separate layout file. It requires a right input which should contain the layout file. It allows you to either do a positional rename which requires the fields to be in the same order or a rename using a field on the layout file.
Other cool things you can do are dynamically renaming multiple filesand using it merge header rows.
By now, you should have expert-level proficiency with the Dynamic Rename Tool! If you can think of a use case we left out, feel free to use the comments section below! Consider yourself a Tool Master already? Let us know at community@alteryx.com if you’d like your creative tool uses to be featured in the Tool Mastery Series.
Stay tuned with our latest posts everyTool Tuesdayby followingAlteryxon Twitter! If you want to master all the Designer tools, considersubscribingfor email notifications
This is one of my favorite tools because we can't always guarantee our data source is going to be consistent which means a new field could come in as a field we are creating. This can reek all kinds of havoc, so instead we add a prefix at the beginning and remove it at the end of the workflow for all the column headers. A common one is "Value", because when you preform a Transpose in Alteryx it changes the columns to a "Name" and "Value" pair. I also use it to indicate calculations "Computed_ColumnName" or "Alteryx_ColumnName" so its easier to tell where the Field came from when working with reporting/troubleshooting.
Is this tool able to achieve the following? I cannot get it to work to meet my requirement as laid out in the following thread:
Can the dynamic Rename tool be used to change the data? I used an IF THEN statement, but nothing changed in my data. I am trying to change the letters of acronyms to match another data source e.g. IF [_CurrentField_]=="HV" THEN "FHEV" ELSE [_CurrentField_] ENDIF