# NullCount 脚本函数

NullCount() 用于返回表达式中聚合的 NULL 值的数量，该数量由 group by 子句定义。

语法：

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

返回数据类型： 整数

参数：

参数

| 参数 | 描述 |
| --- | --- |
| expr Expression | 表达式或字段包含要度量的数据。 |
| distinct | 如果在表达式前出现单词 distinct，则将忽略所有重复值。 |

示例和结果：

将示例脚本添加到您的应用程序并运行它。然后，至少要将结果列中列出的字段添加到我们应用程序中的工作表才能查看结果。

为了获得与下面结果列相同的外观，在属性面板中，在排序下方，从自动切换到自定义，然后取消选择数字和字母排序。

脚本示例

| 示例 | 结果 |
| --- | --- |
| `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:` `LOAD  Customer,NullCount(OrderNumber) as NullOrdersByCustomer Resident Temp Group By Customer;<br>` ` `<br><br>`LOAD NullCount(OrderNumber) as TotalNullCount Resident Temp;` | `Customer NullOrdersByCustomer` `Astrida 0` `Betacab 0` `Canutility 1`<br><br>第二个语句指定：<br><br>`TotalNullCount` `1`<br><br>在包含该维度的表格中，因为只有一条记录包含 NULL 值。 |