Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Renaming a field based on whether it contains a certain word

wht822
7 - Meteor

Hello,

 

I'm trying to find a way to change the name of a field based on whether it contains a certain word. For example, if F1 contains the word "quantity" then I want to rename the field to quantity. If not, then I want to ask if F1 contains the word "price." If it does, then I want it to be renamed "price."

 

Currently, I'm using dynamic rename and entering the following expression:

 

IF "Quantity" THEN "Quantity" ELSEIF "Price" THEN "Price" ELSE "0" ENDIF

 

I've tried using IF Contains in the tool, but it's been unsuccessful. Any help would be appreciated!

4 REPLIES 4
fmvizcaino
17 - Castor
17 - Castor

Hi @wht822 ,

 

Take a look at the attached example. I'm using the same as you, only needed to adjust a bit the formula.

 

Let me know if that works for you.

Best,

Fernando Vizcaino

jrgo
14 - Magnetar

Hi @wht822 

 

Based off what you explained you attempted to do with the Dynamic Rename tool, I'm guessing what you're trying to do is rename a field if the ROW DATA contains that word. If correct, your attempt will not work as that tool only evaluates the headers, not the data within.

 

Take a look at the example attached to see one way to change a column name based on matching something within the data.

Jimmy
Teknion Data Solutions

wht822
7 - Meteor

Fernando, thanks for the reply! Unfortunately, for some reason or another, the solution didn't work. The dataset I'm using does contain many null values as well as random types of data in each field (addresses, names, dates, account numbers, etc). Would this have any bearing on the effectiveness of the formula?

fmvizcaino
17 - Castor
17 - Castor

Hi @wht822 ,

 

I have created a way to rename the field if the header contains a part of the string. But if you need to check if any row of your data contain that specific string in order to rename the column, the solution @jrgo does exactly what you need.

Best,

Fernando V.

Labels