/    /  Amazon QuickSight – isNull

Amazon QuickSight – isNull

 

In Amazon QuickSight isNull is a function that checks if the specified expression is null and returns a Boolean value indicating whether it is true or false. 

Syntax

#Start#
isNull(expression)
#End#

 

This function takes one argument

  1. expression: The expression to be evaluated for null. If the expression is null, the function returns true; otherwise, it returns false.

 

For example, let’s say we have a QuickSight dataset with a field called “Sales” that contains numerical values but may have missing values. We can use the isNull() function to identify records with missing sales values. The following expression returns true for records where the “Sales” field is null and false otherwise:

Example

#Start#
isNull({Sales})
#End#

 

In this example, {Sales} is a reference to the “Sales” field in the dataset. If the “Sales” field is null for a particular record, the expression evaluates to true; otherwise, it evaluates to false.

 

Another example is if we have a dataset with a field “Price” that sometimes has null values. We can use the isNull() function to replace null values with a default value of 0. The following expression returns the value of the “Price” field if it is not null, and 0 otherwise:

Example

#Start#
ifelse(isNull({Price}), 0, {Price})
#End#

 

In this example, ifelse() is a conditional function that returns the first argument if the expression in the second argument is true and the third argument if it is false. The first argument is isNull({Price}), which returns true if the “Price” field is null. Therefore, if the price field is null, the expression returns 0, and if it is not null, it returns the original price value.