I've got three fields
Value1 | Value2 | Operator |
1 | 2 | <= |
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?
Solved! Go to Solution.
@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.
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
Really good shout @Qiu . I forgot about the dynamic replace. Someone can probably do a neater job of it, but here's my attempt,
....aaaaand in Python,
@PhilipMannering
I just happened to know it, but you are good to put it in real workflow.
Learned something and thanks.
Thanks @patrick_digan, @PhilipMannering, @Qiu -- the dynamic replace is the way to go. 😁