# 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 |