NOT DAX Operator
NOT inverts the state of a boolean expression, transforming FALSE to TRUE, or TRUE to FALSE.
NOT is an operator and not a function. Because of the precedence rules, the expression that follows NOT might be evaluated in an unexpected way if you think that NOT is a function.
1 2 3 4 5 6 7 8 9 | EVALUATE { -- NOT evaluates the result of the multiplication ( "NOT ( FALSE ) * FALSE" , "" & NOT ( FALSE ) * FALSE ) , -- NOT evaluates the result of the multiplication ( "NOT ( FALSE * FALSE )" , "" & NOT ( FALSE * FALSE ) ) , -- NOT evaluates only the first FALSE function ( "( NOT FALSE ) * FALSE" , "" & ( NOT FALSE ) * FALSE ) } |
Value1 | Value2 |
---|---|
NOT ( FALSE ) * FALSE | TRUE |
NOT ( FALSE * FALSE ) | TRUE |
( NOT FALSE ) * FALSE | 0 |
The following example has the purpose of clarifying that NOT is an operator and not a function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | DEFINE TABLE 'NOT IN' = ADDCOLUMNS ( CROSSJOIN ( { FALSE , TRUE } , SELECTCOLUMNS ( { 0 , 1 , 2 } , "Expression #" , [Value] ) , SELECTCOLUMNS ( { ( FALSE , FALSE ) , ( FALSE , TRUE ) , ( TRUE , TRUE ) } , "List Item 1" , [Value1] , "List Item 2" , [Value2] ) ) , "Expression" , SWITCH ( [ Expression # ] , 0 , "NOT ( " & [Value] & " ) IN …" , 1 , "NOT ( " & [Value] & " IN … )" , 2 , "( NOT " & [Value] & " ) IN …" ) , "Result" , SWITCH ( [ Expression # ] , 0 , NOT ( [Value] ) IN { [List Item 1] , [List Item 2] } , 1 , NOT ( [Value] IN { [List Item 1] , [List Item 2] } ) , 2 , ( NOT [Value] ) IN { [List Item 1] , [List Item 2] } ) ) EVALUATE SELECTCOLUMNS ( VALUES ( 'NOT IN'[Expression] ) , "Expression" , 'NOT IN'[Expression] , "…{ FALSE, FALSE }" , CALCULATE ( VALUES ( 'NOT IN'[Result] ) , 'NOT IN'[List Item 1] = FALSE , 'NOT IN'[List Item 2] = FALSE ) , "…{ TRUE, TRUE }" , CALCULATE ( VALUES ( 'NOT IN'[Result] ) , 'NOT IN'[List Item 1] = TRUE , 'NOT IN'[List Item 2] = TRUE ) , "…{ FALSE, TRUE }" , CALCULATE ( VALUES ( 'NOT IN'[Result] ) , 'NOT IN'[List Item 1] = FALSE , 'NOT IN'[List Item 2] = TRUE ) ) ORDER BY [ … { FALSE , FALSE } ] ASC |
Expression | …{ FALSE, FALSE } | …{ TRUE, TRUE } | …{ FALSE, TRUE } |
---|---|---|---|
NOT ( FALSE ) IN … | false | true | false |
NOT ( FALSE IN … ) | false | true | false |
( NOT FALSE ) IN … | false | true | true |
NOT ( TRUE ) IN … | true | false | false |
NOT ( TRUE IN … ) | true | false | false |
( NOT TRUE ) IN … | true | false | true |
Last update: Jan 31, 2023 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber, Martin de la Herran