Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Tool Mastery

Explore a diverse compilation of articles that take an in-depth look at Designer tools.
Become a Tool Master

Learn how you can share your expertise with the Community

LEARN MORE

Tool Mastery | Dynamic Rename

HenrietteH
Alteryx
Alteryx
Created

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 formulareplacechar(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 the 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 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.

 

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

 

 

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

Attachments
Comments
andrewdatakim
12 - Quasar
12 - Quasar

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. 

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

LWAGNER2
5 - Atom

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