nullif(X;Y)

Returns N/A if the two given values match.

Syntax

nullif(X;Y)

Input

Argument Type Description
X any simple type A column name
Y any simple type A scalar value or the name of a column
Note: X and Y must be the same type.

Return Value

Returns N/A if the value in column X is equal to Y. Otherwise, returns the value in column X.

If the value in column X is N/A, the result is N/A.

Sample Usage

X Y nullif(X;Y)
1 999 1
999 999 NA
NA 999 NA

Example

Let's use the table pub.demo.retail.item to illustrate the use of nullif(X;Y).

Let's say we want to change the -1 values in the units column to N/A, but we want to keep all the other values the same. To do this, we can create a new computed column that contains the desired results by using the following Macro Language code:
<willbe name="new_units" value="nullif(units;-1)"/>

This will give us the following new column: