Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Multi-Field formula Malformed If statement

Lichunhuang
7 - Meteor

 Hi, Can someone help me with my if statement below? thank you!

 

IF ISNULL([_CurrentField_])
THEN [_CurrentField_]

ELSEIF REGEX_Match([_CurrentField_],"[A-Z]*")

THEN "CONTAINS([" + tostring([Filter 1])+'],"' + tostring([_CurrentField_]) + '")'"

ELSE "aa"

ENDIF

 

 

11 REPLIES 11
shreyanshrathod
11 - Bolide

@Lichunhuang, in the second THEN you should not use doube quotes before CONTAiNS formula.

Also, the use of CONTAins seems inappropriate as it will return boolean TRUE or False and then you are adding that with Current_Field.

 

Regards,

Shreyansh

Luke_C
17 - Castor

Hi @Lichunhuang 

 

If I understand correctly your quotes are out of order in the last part of your then clause: + '")'"

 

Try this: + '")"'

messi007
15 - Aurora
15 - Aurora

@Lichunhuang,

 

Looks like you have problem with the last clause :

 

THEN CONTAINS([_CurrentField_],"'[' + tostring([Filter 1])+']',tostring([_CurrentField_]))

 

Could you Explain what you want to do with this condition

 

I changed with "test" and it works

 

IF ISNULL([_CurrentField_])
THEN [_CurrentField_]
ELSEIF REGEX_Match([_CurrentField_],"[A-Z]*")
THEN "test"
ELSE "aa"
ENDIF

 

Regards,

Lichunhuang
7 - Meteor

Hi, the second one is a string, but not a formula.  The final text looks like this: CONTAINS([GC],"BC")    That is why I put quotes.

atcodedog05
22 - Nova
22 - Nova

Hi @Lichunhuang 

 

Can you provide some sample input and expected output it will help us get a better understanding of the usecase.

Lichunhuang
7 - Meteor

THEN "CONTAINS([" + tostring([Filter 1])+'],"' + tostring([_CurrentField_]) + ")"

For this part , it works well in my workflow, but when I add REGEX_Match([_CurrentField_],"[A-Z]*") , It shows  something wrong.  I guess this is the part causing the problem.

 

atcodedog05
22 - Nova
22 - Nova

Hi @Lichunhuang 

 

Change REGEX_Match([_CurrentField_],"[A-Z]*") to REGEX_Match(tostring([_CurrentField_]),"[A-Z]*")

 

adding tostring

 

Hope this helps : )

 

shreyanshrathod
11 - Bolide

Remove the last double quotes n the second THEN clause. Works good.

THEN "CONTAINS([" + tostring([Filter 1])+'],"' + tostring([_CurrentField_]) + '")'. 

Luke_C
17 - Castor

Hi @Lichunhuang 

 

I am pretty certain it is the ordering of your single and double quotes in the then statement. I tweaked it to this and it works. See my above post for the issue.

 

IF ISNULL([_CurrentField_])
THEN [_CurrentField_]

ELSEIF REGEX_Match([_CurrentField_],"[A-Z]*")

THEN "CONTAINS([" + tostring([Filter 1])+'],"' + tostring([_CurrentField_]) + "')'"

ELSE "aa"

ENDIF

Labels