Alteryx Designer Desktop Discussions

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

Logic conversion using tools

Fizzledrizzle
7 - Meteor

I'm trying to convert a string of logical operators to alteryx readable operators. Below is an example of what I have in a string field:

 

OR(AND([Field1]==0,[Field2]!=0),AND([Field1]>=[Field3],!(AND([Field1]==0,[Field4]==0, [Field6]>0))))

 

I need to figure out a way to transform the above, using formulas or some other tools, to be similar to how Alteryx likes logic and still store it in a string:

 

(([Field1]==0 && [Field2]!=0) ||([Field1]>=[Field3] && !(([Field1]==0 && [Field4]==0 && [Field6]>0))))

 

I can see how to do this manually, and what I am struggling with is how to use some functionality in Alteryx to convert the input to the output. I receive hundreds of these logical strings on a spreadsheet, and I know how to assign them provided I can convert the logic to and Alteryx friendly version. 

 

Any help would be greatly appreciated. 

4 REPLIES 4
JarekSkudrzyk
11 - Bolide

@Fizzledrizzle hi, one question - are "OR" and "AND" the only operators used in those logical strings you have mentioned?
I am trying to figure out a regex-based solution that could help you.

Fizzledrizzle
7 - Meteor

@JarekSkudrzyk Yes, the only logical operators I receive are "AND" and "OR". Just to throw a wrench in things we found that sometimes there are other functions given as arguments. such as:

AND([Field4]!=0,DateTimeMonth([Field8])==12)

 

which would need to be 

 

([Field4]!=0 && DateTimeMonth([Field8])==12)

I found this one out after I had posted the problem. 

 

Thank you for your help with this.

Fizzledrizzle
7 - Meteor

I solved it!

it took a few passes at the data, and I added a few more, just in case. 

 

@JarekSkudrzyk Thank you for the hint about the regex based solution. This ended up being the way to go.

JarekSkudrzyk
11 - Bolide

@Fizzledrizzle congrats! I am glad I could help with my hint:)

Labels