Logical negation operator (!)

!Value

Value

Logical or { Logical }

The value to negate.

Returns

Logical or { Logical }

The negated value.

Negates the logical value, turning TRUE into FALSE and FALSE into TRUE. !TRUE!TRUE returns FALSE and !FALSE!FALSE returns TRUE.

Use !, && and || in conjunction with IF to express logical conditions.

This formula returns 2 only if Field1.ValueField1,Value is 20 and Field2.ValueField2,Value is not 40, and 4 otherwise:

IF((Field1 = 20) && !(Field2 = 40), 2, 4)IF((Field1 = 20) && !(Field2 = 40); 2; 4)

The formula can also be written using the AND and NOT functions:

IF(AND(Field1 = 20, NOT(Field2 = 40)), 2, 4)IF(AND(Field1 = 20; NOT(Field2 = 40)); 2; 4)

&& is written between the values to test, instead of before them, which can make formulas easier to read.

To make the formula even easier to read, consider replacing the second = operator with either the <> operator or the != operator (which mean "not equal to"):

IF((Field1 = 20) && (Field2 <> 40), 2, 4)IF((Field1 = 20) && (Field2 <> 40); 2; 4)

Examples

!FALSE!FALSE

Returns TRUE.

!TRUE!TRUE

Returns FALSE.

!SwitchField1!SwitchField1

Returns FALSE if the switch field is toggled to its "on" position and TRUE otherwise.

!{ TRUE, FALSE, FALSE }!{ TRUE; FALSE; FALSE }

Returns { FALSE, TRUE, TRUE }{ FALSE; TRUE; TRUE }, as each individual array element is negated.

IF((Field1 = 20) && !(Field2 = 40), 2, 4)IF((Field1 = 20) && !(Field2 = 40); 2; 4)

Returns 2 only if Field1.ValueField1,Value is 20 and Field2.ValueField2,Value is not 40, and 4 otherwise.