When you're creating a segmenting using fields from the lead database. You can choose multiple fields.
I get how a series of ANDs would work. And, I get how a series of ORs would work. But, how does a series of ANDs and ORs work?
For example, let's say this is how I build my segmentation, only using the Lead Database object:
Lead Score - Is Greater than - "50"
AND
Department - Is - "IT"
OR
Email Address - Contains - "company.com"
Does that mean:
( Lead Score > 50 AND Department = "IT" ) OR Email Address Contains "company.com"
Or, does that mean:
Lead Score > 50 AND (Department = "IT" OR Email Address Contains "company.com")
Or, does that mean:
(Lead Score > 50 Or Email Address Contains "company.com") AND (Department = "IT" OR Email Address Contains "company.com" Or Email Address Contains "company.com")
Or, something else?
Hi Brandon,
To answer you I am not sure what would be correct from above, but what I can tell you is that if you use brackets () in your criteria you can tell Marketo explicitly which order you would like it in.
So if you do Lead Score And (Department or Email address) then Marketo will go with your second assumption (which you even put in brackets):
Or, does that mean:
Lead Score > 50 AND (Department = "IT" OR Email Address Contains "company.com")
Without the brackets I think the behavior would be very unpredictable.
I wouldn't say "unpredictable" because every rules engine has one fixed way of executing a condition. They're usually left-associative for both AND and OR, plus AND is usually higher precedence than OR, so x AND y OR z is most commonly equivalent to (x AND y) or Z.
x OR y AND z needs a bit more proof: across all languages, it's most commonly x OR (y AND z), but in theory some rules engines are different, and if OR and AND have equal precedence it would be (x OR y) AND z.
But I definitely agree, without brackets it's not immediately apparent. It's the same with over-reliance on associativity + precedence in "real" programming: it may work predictably, but it's not fun to read!
Yeah, that's exactly how I'm assuming it should work. You can't do brackets within the Lead Database object when setting up the segment, so I can't know for sure how it does work.
What I do know is:
____ AND ____ OR Email Address is "my email" ...isn't adding me to the segment as you would expect.
Hello Brandon,
AND and OR have a precedence order. Logical AND statements have a different precedence than OR. Think of it this way:
Multiplication and Division are equal to AND, Addition and Subtraction are equal to OR. So when doing math -> 5 + 5 x 5 = 30 correct? So when using logic True OR False AND False = True. The AND pair is calculated first (FALSE) and the OR pair (which is now True OR FALSE) is now True.
I hope this makes sense. Grouping with () changes this since () are at a higher precedence and are calculated first.
It sounds like my assumptions are correct and the functionality isn't working.
____ AND ____ OR Email Address is "my email"
(Note: I am both in the lead database and Marketo is recognizing my email on prefill forms)
Still isn't working for me. And, that's just my basic test to make sure the logic is working.
Update: I cleared my cache and waited a day. And now it works!
So, the logic works as you'd expect, just beware of your cache.