# TextCount - 脚本函数

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

语法：

TextCount (TextCount ( [ distinctdistinct ] expr ] expr))

返回数据类型： 整数

参数：

参数

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

示例和结果：

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

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

示例：

`Temp:` `LOAD * inline [` `Customer|Product|OrderNumber|UnitSales|UnitPrice` `Astrida|AA|1|4|16` `Astrida|AA|7|10|15` `Astrida|BB|4|9|9` `Betacab|CC|6|5|10` `Betacab|AA|5|2|20` ` Betacab|BB|||  25  ` `Canutility|AA|||15` `Canutility|CC| ||19` `Divadip|CC|2|4|16` `Divadip|DD|3|1|25` `] (delimiter is '|');` `TextCount1:` `LOAD  Customer,TextCount(Product) as ProductTextCount Resident Temp Group By Customer;
`

结果表

| Customer | ProductTextCount |
| --- | --- |
| Astrida | 3 |
| Betacab | 3 |
| Canutility | 2 |
| Divadip | 2 |

示例：

` LOAD Customer,TextCount(OrderNumber) as OrderNumberTextCount Resident Temp Group By Customer;
                 `

结果表

| Customer | OrderNumberTextCount |
| --- | --- |
| Astrida | 0 |
| Betacab | 1 |
| Canutility | 2 |
| Divadip | 0 |