Null Operators

Use is null and is not null to check whether a value is or is not null. is null returns True when a value is null. is not null returns True when a value is not null.

This example returns rows that contain Sub_Category fields that are not null and the counts of rows that contain each field.

1q = load "Superstore";
2q = filter q by 'Sub_Category' is not null;
3q = group q by 'Sub_Category';
4q = foreach q generate 'Sub_Category' as 'Sub_Category', count() as 'count';
5q = limit q 2000;
Sub-CategoryCount of Rows
Accessories775
Appliances466
Art796
Binders1,523
Bookcases228
Chairs617
Copiers68
Envelopes254
Fasteners217
Furnishings957
Labels364
Machines115
Paper1,370
Phones889
Storage846
Supplies190
Tables319

Replace Null Values with case 

Use case to replace null values with a value of your choice. This example labels the null Sub-Category field “Empty.”

1q = load "Superstore";
2q = group q by 'Sub_Category';
3q = foreach q generate case when 'Sub_Category' is null then "Empty" else 'Sub_Category' end as 'Sub_Category', count() as 'count';
4q = limit q 2000;
Sub-CategoryCount of Rows
Accessories775
Appliances466
Art796
Binders1,523
Bookcases228
Chairs617
Copiers68
Envelopes254
Fasteners217
Furnishings957
Labels364
Machines115
Paper1,370
Phones889
Storage846
Supplies190
Tables319
Empty4

See Also