# NullCount - script function

NullCount() returns the number of NULL values aggregated in the expression, as defined by a group by clause.

Syntax:

NullCount (NullCount ( [ distinctdistinct ] expr ] expr))

Return data type: integer

Arguments:

NullCount arguments

| Argument | Description |
| --- | --- |
| expr | The expression or field containing the data to be measured. |
| distinct | If the word distinct<br>occurs before the expression, all duplicates are disregarded. |

Examples and results:

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in our document to see the result.

Examples and results

| Example | Result |
| --- | --- |
| `Set NULLINTERPRET = NULL;`<br>`Temp:`<br>`LOAD  * inline [`<br>`Customer\|Product\|OrderNumber\|UnitSales\|CustomerID`<br>`Astrida\|AA\|1\|10\|1`<br>`Astrida\|AA\|7\|18\|1`<br>`Astrida\|BB\|4\|9\|1`<br>`Astrida\|CC\|6\|2\|1`<br>`Betacab\|AA\|5\|4\|2`<br>`Betacab\|BB\|2\|5\|2`<br>`Betacab\|DD\|\|\|`<br>`Canutility\|AA\|3\|8\|`<br>`Canutility\|CC\|NULL\|\|`<br>`] (delimiter is '\|');`<br>`Set NULLINTERPRET=;`<br>`NullCount1:`<br>`LOAD  Customer,NullCount(OrderNumber) as NullOrdersByCustomer Resident Temp Group By Customer;<br>`<br>` `<br><br>`LOAD NullCount(OrderNumber) as TotalNullCount Resident Temp;` | `Customer NullOrdersByCustomer`<br>`Astrida 0`<br>`Betacab 0`<br>`Canutility 1`<br><br>The second statement gives:<br><br>`TotalNullCount`<br>`1`<br><br>in a table with that dimension, because only one record contains a null value. |