# GetExcludedCount

GetExcludedCount() 用于查找标识字段中排除的相异值的数量。只计算排除在外（灰色单元格、白色文字）的数值。替代值（白色单元格、灰色文字）和选定排除值（灰色单元格、绿色文字）不计算在内。

语法：

GetExcludedCount (field\_name)

返回数据类型： 字符串

参数：

* field\_name： 包含要度量的数据范围的字段。

下表列出了与此函数相关的其他函数。

相关函数

| 函数 | 交互 |
| --- | --- |
| [GetStateCounts](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getstatecounts.htm) | 使用 GetStateCounts()，您可以使用单个函数调用组合以下计数的计算：<br><br><ul> <li> <p>所选包含值的计数。</p> </li> <li> <p>可能的值计数。</p> </li> <li> <p>取消选择的值的计数（仅当字段处于“和”模式时可用）。</p> </li> <li> <p>替代值的计数。</p> </li> <li> <p>排除值的计数，不包括替代和选定的排除值。</p> </li> <li> <p>所选排除值的计数。</p> </li> </ul> |
| [GetSelectedCount](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getselectedcount.htm) | 返回所选包含值的计数。 |
| [GetPossibleCount](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getpossiblecount.htm) | 返回可能值的计数。 |
| [GetNotSelectedCount](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/GetNotSelectedCount.htm) | 返回取消选择的值的计数（仅当字段处于和模式时可用）。 |
| [GetAlternativeCount](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getalternativecount.htm) | 返回替代值的计数。 |

## 列表框内选择项状态的颜色

本页面的全部信息都是指在特定设置下列表框中选择项状态的颜色：

* QlikView 文件配置为经典扩展色彩方案。请参阅： [选择项外观](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/Document_Properties_General.htm#SelectionAppearance)

* 列表框配置为打开显示替代。请参阅： [显示替代项](https://help.qlik.com/zh-CN/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/List_Box.htm#ShowAlternatives)

下表概述了使用此配置的列表框内各选择项状态的配色方案。

给定配置时列表框的配色方案

| 状态 | 单元颜色 | 文本颜色 |
| --- | --- | --- |
| 替代 | 白色 | 灰色 |
| 取消选择 | 红色 | 黑色 |
| 排除值 | 灰色 | 白色 |
| 可能 | 白色 | 黑色 |
| 选定 | 绿色 | 黑色 |
| 选定排除值 | 灰色 | 绿色 |

## 示例

以下示例使用加载到不同列表框的三个字段：一个用于 First name、一个用于 Last name，一个用于 Initials。

示例 1: 如果未在 First name 中选择任何值。

`GetExcludedCount  (Initials)`

返回 0，没有选择项。

示例 2: First name 中选择了 John

`GetExcludedCount  (Initials)`

返回 5。 Initials 中有 5 个灰色排除值。 JA 值将为白色，因为它与 First name 中的选择 John 相关联。

示例 3: 已在 First name 中选择 John 和 Peter。

`GetExcludedCount  (Initials)`

返回 3。John 与 1 个值相关联，Peter 与 Initials 中的 2 个值相关联。

示例 4: 在 First name 中选择了 John 个 Peter，在 Last name 中选择了 Franc

`GetExcludedCount ([First name])`

返回 3。First name 中有 3 个排除值，颜色为深灰色。GetExcludedCount() 仅计算排除的值。备选和选定的排除值不包括在计数中。

示例 5: 在 First name 中选择了 John 和 Peter ，在 Last name 中选择了 Franc 和 Anderson

`GetExcludedCount  (Initials)`

返回 4。 Initials 中有 4 个灰色排除值。其他两个值（JA 和 PF）将为白色或浅黄色，因为它们与 First name 中的选择 John 和 Peter 相关联。

示例 6: 在 First name 中选择了 John 和 Peter ，在 Last name 中选择了 Franc 和 Anderson

`GetExcludedCount  ([Last name])`

返回 3。Last name 中有 3 个排除的值：Brown、Carr 和 Elliot。值 Devonshire 是一个替代值，因此不计入计数。

示例中所使用的数据：

`Names:` `LOAD * inline [` `"First name"|"Last name"|Initials|"Has cellphone"` `John|Anderson|JA|Yes` `Sue|Brown|SB|Yes` `Mark|Carr|MC |No` `Peter|Devonshire|PD|No` `Jane|Elliot|JE|Yes` `Peter|Franc|PF|Yes ] (delimiter is '|');`