When it comes to column headers, it is either already there or we would manually type it in (e.g. with formula tool to create new columns; use select tool to rename columns etc.). What if we need the column names to be dynamic from another input? Let’s start with an example:

We have 2 tables here. One table contains exchange rate information and the other one contains dates which shall be headers for the first table. Since the dates are dynamically extracted, we cannot simply update the column names manually. So, how can we change the headers with a dynamic input?

Solution: use the Dynamic Rename tool.

Let’s see how it works.

Step 1: Union the two tables by Position and make sure the header table is #1 in the output order list when doing the union and that each header is at the correct column. If the headers are not at the correct column or some column names are not available (e.g. “Currency” is not a dynamic input), use Formula tool to add new column names and Select tool to change column position.

Step 2: Connect the Dynamic Rename tool and choose Rename Mode: Take field names from first row of data. Job done, we got the headers!

Now, the Dynamic Rename tool is very powerful and it can be used in many different ways. Let’s have a look at some other examples.

We have the same exchange rate table, but because we dynamically extracted the dates, the header table looks like this:

Of course we can Cross Tab it and use formula tool to add another column called Currency. We can also use another rename mode of the Dynamic Rename tool: Take field names from Right input rows. In this case, we will use the Select tool to separate the static columns that we do not need rename and the dynamic columns that require rename. Then connect Dynamic Rename tool to rename headers with input rows from the Right anchor. After that, we can simply join the fields back with the Join tool by record position to get the full data.

Hope you find this blog useful. There are many other rename modes in the Dynamic Rename tool. Go check them out!



The Data School
Author: The Data School