Alteryx Designer Desktop Discussions

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

Dynamic Rename Formula Renaming Columns that Do Not Meet Criteria

courtneyq
7 - Meteor

Hello, my dynamic rename formula has been renaming both columns even though the second one does not meet the criteria which is no spaces, numbers, punctuation and must be between 3 - 15 characters in length. 

 

Weirdly when running the different formula tools, the formula is returning the correct values. 

 

The "val" heading should not be renamed to "Username" just the "Name "column: 

Issue.pngIssue.png

 

Any tips or guidance helps!

 

7 REPLIES 7
Raj
16 - Nebula

@courtneyq 
formula updated

If length([_CurrentField_])> 3 AND
length([_CurrentField_])<= 15 AND
!contains([_CurrentField_], " ") AND
!contains([_CurrentField_], "0") AND
!contains([_CurrentField_], "1") AND
!contains([_CurrentField_], "2") AND
!contains([_CurrentField_], "3") AND
!contains([_CurrentField_], "4") AND
!contains([_CurrentField_], "5") AND
!contains([_CurrentField_], "6") AND
!contains([_CurrentField_], "7") AND
!contains([_CurrentField_], "8") AND
!contains([_CurrentField_], "9") AND
!contains([_CurrentField_], "!") AND
!contains([_CurrentField_], "@") AND
!contains([_CurrentField_], "#") AND
!contains([_CurrentField_], "$") AND
!contains([_CurrentField_], "%") AND
!contains([_CurrentField_], "^") AND
!contains([_CurrentField_], "&") AND
!contains([_CurrentField_], "*") AND
!contains([_CurrentField_], "(") AND
!contains([_CurrentField_], ")") AND
!contains([_CurrentField_], "_") AND
!contains([_CurrentField_], "-") AND
!contains([_CurrentField_], "+") AND
!contains([_CurrentField_], "=") AND
!contains([_CurrentField_], "{") AND
!contains([_CurrentField_], "[") AND
!contains([_CurrentField_], "}") AND
!contains([_CurrentField_], "]") AND
!contains([_CurrentField_], "|") AND
!contains([_CurrentField_], "\") AND
!contains([_CurrentField_], ":") AND
!contains([_CurrentField_], ";") AND
!contains([_CurrentField_], "<") AND
!contains([_CurrentField_], ".") AND
!contains([_CurrentField_], ">") AND
!contains([_CurrentField_], "?") AND
!contains([_CurrentField_], "/") AND
!contains([_CurrentField_], ",") AND
!contains([_CurrentField_], "~")

Then "Username"

else [_CurrentField_] endif

find workflow attached
mark done if solved.

DataNath
17 - Castor

Hey @courtneyq, the Dynamic Rename tool evaluates the field names themselves and not the column values. Therefore, you're checking whether 'Name' and 'Val' satisfy your conditions, which they do, hence why they're both being converted to 'Username' - are you trying to do this or just change the values within the column? If it's the former you'll have to build in some extra logic/checks to exclude 'Val' from being changed.

Raj
16 - Nebula

@courtneyq 
insted you can use 

"IF Regex_Match([_CurrentField_], '^[a-zA-Z]{4,15}$') THEN "Username" ELSE [_CurrentField_] ENDIF"

easy to understand.

DataNath
17 - Castor

@Raj one of the checks mentioned in the original post is that the length must be 3-15 characters. Starting your checks off with:

 

If length([_CurrentField_])> 3 AND
length([_CurrentField_])<= 15 AND

 

Ensures that this is 4-15 characters.

Raj
16 - Nebula

@DataNath as he mentioned between 3-15 and as per his condition 
"Val" should not be included 
i updated it.

courtneyq
7 - Meteor

@DataNath How can I change the column headers based on whether the values below it meet the criteria? I did not realize the dynamic rename only looks at the value of the headers.

Erin
10 - Fireball

Glad that you have the RegEx squared away and I think you were on the right path by flipping the data around with Transpose & Crosstabs tools. I think this is related to this other post, right? I added a workflow there:

https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Automatically-Rename-Column-if... 

Labels