Alteryx Designer Desktop Discussions

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

Is there a way to use a string/text "formula" as an expression in Designer?

tmlmark
7 - Meteor

I've got three fields

 

Value1Value2Operator
12<=

 

I need to be able to build an expression from those three fields that reads something like:

"If Value2 | Operator | Value1" then etc.

 

I can construct a literal string that reads "if 2<=1" but I can't figure out how to make Alteryx interpret that as an expression.

 

Any thoughts?

6 REPLIES 6
patrick_digan
17 - Castor
17 - Castor

@tmlmark Alteryx should add an eval function which would solve this! Until then, the out of the box solution is the dynamic replace. It has some really good examples if you open that in alteryx. For a third party solution, the crew macro dynamic formula could get you most of the way there. 

tmlmark
7 - Meteor

Thanks @patrick_digan. I opted for a more brute force IF statement. 

 

If OPERATOR = "<=" and Value1 <= Value2 then 1 elseif

OPERATOR = ">" and Value1 > Value2 then 1 

...etc.... else 0 endif

 

Would like to see your Eval idea implemented.

 

Mark

 

 

Qiu
20 - Arcturus
20 - Arcturus

@tmlmark 

I think you might be looking for Dynamic Replace?

Capture1.PNG

PhilipMannering
16 - Nebula
16 - Nebula

Really good shout @Qiu . I forgot about the dynamic replace. Someone can probably do a neater job of it, but here's my attempt,

PhilipMannering_0-1614901719918.png

 

....aaaaand in Python,

PhilipMannering_1-1614901736634.png

 

Qiu
20 - Arcturus
20 - Arcturus

@PhilipMannering 
I just happened to know it, but you are good to put it in real workflow.

Learned something and thanks.

tmlmark
7 - Meteor

Thanks @patrick_digan@PhilipMannering@Qiu -- the dynamic replace is the way to go. 😁

Labels