# NOT operator for expressions

Is there a NOT operator available for filter expressions? I want to create the expression:
[ A = B AND NOT( C = False AND D = True) ].
Now I’m using
[ A = B AND ( C = True OR ( C = False AND D = False ) ) ]
but it feels unnecessarily complicated.

Absolutely. You can use the ≠

The following items would be correct:
A = B AND C=True AND D=True
A = B AND C=True AND D=False
A = B AND C=False AND D=False

And this one would be incorrect
A = B AND C=False AND D=True

So the expression to go would be:
A = B AND (C ≠ False AND D ≠ True)

By using the brackets, the system first calculates C’s not False AND D’s not True. And if that’s the case it checks if A=B.

2 Likes

Thanks! I guess I’m not used to using the ≠ in building expressions 1 Like

I’m still struggling with how:
NOT ( C = False AND D = True ).
would be equivalent to
C ≠ False AND D ≠ True.

In the case of C = True, D = True:

NOT ( C = False AND D = True )
= NOT ( True = False AND True = True )
= NOT ( False AND True )
= NOT ( False )
= True.

However,
C ≠ False AND D ≠ True
= True ≠ False AND True ≠ True
= True AND False
= False.

So it seems to me they are not equivalent expressions?

Hi Sjoerd,

You’re absolutely right… Your initial filter

A = B AND ( C = True OR ( C = False AND D = False ) )

was correct and mine was wrong.

That’s OK But this doesn’t answer my question: is there a NOT operator available? Because right now I have to rewrite the logic of the expression just to avoid NOT, which makes it quite a bit more complicated and less intuitive. I know the exception cases where the filter should apply, now I have to make a logic table to determine the expression where the filter should not apply.

Hi Sjoerd,
I can understand you would like to use a NOT operator. However, for now we don’t support it. Maybe we’ll support it in the future.

I’ll put it on our backlog, but the NOT-operator itself is an operator known from SQL-statements, and it’s not our general intention to copy SQL statements. Since the same behaviour can be achieved with the current operators, for now we chose not to add the NOT operator.

1 Like

Well, NOT is one of the three basic operators for Boolean logic in general, not just an operator in SQL. I feel like leaving out this basic operator sacrifices intuitive functionality for (over)simplicity here. But thanks for the explanation and adding it to the backlog!

2 Likes