Alteryx Tools in Focus: Dynamic Replace and Dynamic Rename

5 March 2015
This blog post is going to introduce the power and simplicity of the Dynamic Replace and Dynamic Rename tools in Alteryx. I don't often explore the 'Developer' set of tools but was pleasantly surprised at how easily they allowed me to deal with a data preparation problem I was facing. I've prepared a simple case study to talk you through how I used them.

Introduction

Here at The Information Lab we keep finding scenarios where Alteryx really makes our Tableau experiences a whole lot easier. This blog post is going to introduce the power and simplicity of the Dynamic Replace and Dynamic Rename tools in Alteryx. I don't often explore the 'Developer' set of tools but was pleasantly surprised at how easily they allowed me to deal with a data preparation problem I was facing.  I've prepared a simple case study to talk you through how I used them. Hopefully it will set you up for similar success if you're already using Alteryx, and if you're not, it might just give you a reason to take a closer look at the product (our FREE Alteryx for Tableau Users training sessions are a great place to start - link).

Background

So let me set the scene. I've got some data I want to prep for use in Tableau. Its what I'd consider a typical table of data with dimensions and measures, but on closer inspection the individual attributes have been stored elsewhere, together with the actual dimension names. Perhaps that's more easily processed by taking a look at such a data table, so here it is:

Figure 1

IDColAColBColCMeasure
1GB131000
2GB33234
3FR2334
4GB2233
5FR1233
6I3144
7I1280
8I21256
9BR113009
10FR2233
With the attributes of ColA, ColB and ColC stored separately, as part of a master list of possible values:

Figure 2

FieldValueLabel
ColAUKUnited Kingdom
ColAFRFrance
ColADGermany
ColAIItaly
ColB1Tableau Desktop
ColB2Tableau Online
ColB3Tableau Reader
ColC1Data Analyst
ColC2BI Analyst
ColC3DBA
ColC4IT Manager
ColD1Fundamentals
ColD2Advanced
In a similar manner, the dimension names are here:

Figure 3

ColumnLabel
ColACountry
ColBProduct
ColCRole

What to Do?

'That's interesting' was my first thought!Initially I thought a solution would be a basic JOIN tool to resolve out each column in turn. So that was quickly implemented for one column, but looking across what in reality was 10+ columns you could see it was going to get a little tedious and the end result would not be very generic.I did ponder for a moment if a SQL based solution might work, again, repeating a number of joins for each column, but I'd end up with a query specific to just this arrangement of columns. I wanted something a little more dynamic. Time to explore the Developer toolset where I'd heard a better solution might be found.....

Dynamic Replace

DynamicReplaceSo the Dynamic Replace tool is the answer. Lets a look at this tool in a little more detail. We've got 2 inputs, one is Data and one is the Replace logic. My aim with this tool is to replace all values in one pass. In short the logic defined within the R input will be applied across all data in the D input.One subtlety to note is that I've got a mix of data types within my data, so I'm going to ensure all have been converted to strings before I hit this tool.So what do I need to do to prepare the replace logic? Its pretty simple, I just need to define an expression, and the expression will be based upon the _CurrentField_ variable. From the below you can see why I aligned to strings values on my Data input.

Figure 4

ExpressionThe eagle eyed amongst you might notice a subtle difference in Figure 4 compared to Figure 2 above. I've actually applied a filter to remove labels for ColD. The replace tool will error if you supply expressions for a column not in the Data input.So onto the configuration of the Dynamic Replace tool. Its pretty simple, just 3 key options to set, all referencing what you can see in Figure 4
  1. What is the name of the column which identifies the fields in my Data input - that is the Field column
  2. Where is the expression - that's the Expression column
  3. What do I want to output when the expression is evaluated and returns TRUE - that's the Label column

Figure 5

ReplaceConfigWhen I look at the Output of the tool, I get what I'm after:

Figure 6

ReplaceOutputThe Summary output of the tool just gives you an overview of how the Replace logic was applied.So to recap I've used the Dynamic Replace tool to perform a 'like for like' replace, a specific value has been replaced with another. However my expression could have been any formula, where a replacement is applied when it evaluates to TRUE. I could have tested a numeric field against a range for instance.Back to my example, where we just have the column headers to tidy up....

Dynamic Rename

DynamicRenameThe tool we need for this task is Dynamic Rename. In this case we've got a Left and an optional Right input. There are a variety of configuration options here. If you just have a single Left input you can use formulas to edit the column headers or amend specific prefix/suffixes etc. If you include a Right input, then you can use values from this input to rename the headers in the Left.

Figure 7

RenameConfig1I'm going to choose the highlighted option above. Into the Left I'm going to route the output from my Dynamic Replace, and into the Right I'm going to route the column headers which I'll reproduce here:

Figure 8

ColHeadersThe final piece of configuration is to identify which is the old value - Column, and which is the new value - Label.

Figure 9

RenameConfig2With that, we just need to play the module and we have our final output:

Figure 10

OutputThe elegance of this workflow is that its generic, we can re-use it or we could even turn it into a macro which accepts the location of the 3 input files. For me, that's a lot of data preparation time saved.I've packaged up a zip of the workflow and the sample data for download from here. The Data Input tools all reference the included Excel file, which I'd located in c:dynamic.
Author:
Mike Lowe
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Information Lab and data industry
Subscribe now
© 2025 The Information Lab