community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx Knowledge Base

Definitive answers from Designer experts.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE

Tool Mastery | Dynamic Rename

Alteryx
Alteryx
Created on

dynamic rename.pngThis 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: 

 

9-14-2016 4-09-32 PM.png  

 

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 formula replacechar(regex_replace([_CurrentField_],"Sum_",""),"_"," ") in the Dynamic Rename Tool removes "Sum_" and the underscores:

9-14-2016 4-22-16 PM.png

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. 

 

9-14-2016 4-36-17 PM.png

 

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 a right input. 

 

9-14-2016 4-39-36 PM.png

 

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 wich 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.

 

9-14-2016 4-47-56 PM.png

 

 See the attached v10.5 workflow for the examples above in Alteryx. 

 

Other cool things you can do are dynamically renaming multiple files and 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 every Tool Tuesday by following Alteryx on Twitter! If you want to master all the Designer tools, consider subscribing for email notifications

Attachments
Comments
Alteryx Partner
Alteryx Partner

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. 

Meteor

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:

 

https://community.alteryx.com/t5/Data-Preparation-Blending/How-to-dynamically-rename-a-header-in-to-...