Alteryx Designer Desktop Discussions

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

does not contain filter

neilgallen
12 - Quasar

Apologies but brain struggling to work. There's probably a simple explanation to this one that I'm missing.

 

Why would a filter with 

 

Contains([Field],"FREIGHT") or Contains([Field],"TRUCK") output results to the True anchor of the filter, but 

 

!Contains([Field],"FREIGHT") or !Contains([Field],"TRUCK") not output those same results to the False anchor?

 

 

Ultimately it doesn't matter because I can use either anchor, but the logic escapes me at the moment. Interestingly, when the conditions are used separately as does not contain they work fine.

4 REPLIES 4
Kenda
16 - Nebula
16 - Nebula

Hey @neilgallen!

 

In your second expression (where you use the !) - I think you would want to use and instead of or.

 

For example: If the value of one of your records is "FREIGHT" and you use the or operator, it is true that the field doesn't contain "TRUCK" so that record comes out the true side. By using and, the field cannot contain "TRUCK" and it cannot contain "FREIGHT" to come out the true side.

 

Hope this helps!

neilgallen
12 - Quasar

Bingo. Far too little sleep lately! Thanks @Kenda

Kenda
16 - Nebula
16 - Nebula

No problem! Sometimes trying to talk through each step of the logic in your head is helpful, especially when using the NOT operator.

Claje
14 - Magnetar

Breaking down the explanation a little bit

The first statement will apply as follows for four different strings:

The value "FREIGHT" contains the word "FREIGHT", but not the word "TRUCK".  Since you are using the OR operator, since FREIGHT is TRUE, this will be TRUE

The value "TRUCK" does not contain the word "FREIGHT", but contains the word "TRUCK". Since you are using the OR operator, since TRUCK is TRUE, this will be TRUE.

The value "FREIGHT TRUCK" contains BOTH the word "FREIGHT" AND the word "TRUCK".  Since you are using the OR operator, and both conditions are TRUE, this will be TRUE.

The value "AIRPLANE" does not contain the word "FREIGHT" or the word "TRUCK".  As such, it will be FALSE.

 

The second statement, using !contains, is currently saying the following:

The value "FREIGHT" contains the word "FREIGHT", so condition one is FALSE, but not the word "TRUCK", so condition two is TRUE.
Since you are using the OR operator, since !CONTAINS "TRUCK" is TRUE, this will be TRUE

The value "TRUCK" does not contain the word "FREIGHT", so condition one is TRUE, but contains the word "TRUCK", so condition two is FALSE. Since you are using the OR operator, since !CONTAINS "FREIGHT" is TRUE, this will be TRUE.

The value "FREIGHT TRUCK" contains BOTH the word "FREIGHT", so condition one is FALSE, AND the word "TRUCK", so condition two is FALSE.  Since you are using the OR operator, and both conditions are FALSE, this will be FALSE.

The value "AIRPLANE" does not contain the word "FREIGHT", so condition one is TRUE, or the word "TRUCK", so condition two is TRUE.  As such, it will be TRUE.


Because of the way the OR function works, when you are checking for two negative conditions, it will only evaluate to FALSE when BOTH conditions evaluate to FALSE.


As such, using AND will break down as follows:

The value "FREIGHT" contains the word "FREIGHT", so condition one is FALSE, but not the word "TRUCK", so condition two is TRUE.
Since you are using the AND operator (so all conditions must be true for a result to be TRUE), since !CONTAINS "FREIGHT" is FALSE, this will be FALSE.

The value "TRUCK" does not contain the word "FREIGHT", so condition one is TRUE, but contains the word "TRUCK", so condition two is FALSE. Since you are using the AND operator, since !CONTAINS "TRUCK" is FALSE, this will be FALSE.

The value "FREIGHT TRUCK" contains BOTH the word "FREIGHT", so condition one is FALSE, AND the word "TRUCK", so condition two is FALSE.  Since you are using the AND operator, and both conditions are FALSE, this will be FALSE.

The value "AIRPLANE" does not contain the word "FREIGHT", so condition one is TRUE, or the word "TRUCK", so condition two is TRUE.  As such, it will be TRUE, as both conditions are TRUE.

 

I think this is what you are looking for.

Labels