# GetPossibleCount - 图表函数

GetPossibleCount() 用于查找标识字段中可能值的数量。如果标识字段包括选择项，则计算选定（绿色）值的数量。否则，计算相关（白色）值的数量。

对于有选择项的字段，GetPossibleCount() 将返回所选（绿色）字段的数量。

返回数据类型： 整数

语法：

GetPossibleCount (field\_name)

信息注释

选择栏中使用的颜色以及每个选择项状态都可以使用自定义主题进行修改。如果您所用的是使用自定义主题的应用程序，您可能会注意到您的选择显示的颜色与帮助主题中描述的颜色不同。

参数：

参数

| 参数 | 描述 |
| --- | --- |
| field\_name | 包含要度量的数据范围的字段。 |

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

相关函数

| 函数 | 交互 |
| --- | --- |
| [GetStateCounts - 图表函数](https://help.qlik.com/zh-CN/sense/November2024/Subsystems/Hub/Content/Sense_Hub/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></ul> |
| [GetSelectedCount - 图表函数](https://help.qlik.com/zh-CN/sense/November2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getselectedcount.htm) | 返回所选包含值的计数。 |
| [GetAlternativeCount - 图表函数](https://help.qlik.com/zh-CN/sense/November2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getalternativecount.htm) | 返回替代值的计数。 |
| [GetPossibleCount - 图表函数](https://help.qlik.com/zh-CN/sense/November2024/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getpossiblecount.htm#) | 返回排除值的计数，不包括替代和选定的排除值。 |

示例和结果：

以下示例使用两个加载到不同筛选器窗格的字段，一个用于 First name 名称，另一个用于 Initials。

示例和结果

| 示例 | 结果 |
| --- | --- |
| 假定选择 John（在 First name 中）。<br><br>`GetPossibleCount  ([Initials])` | 1，因为 Initials 中有 1 个值与 First name 中的选择项 John 关联。 |
| 假定选择 John（在 First name 中）。<br><br>`GetPossibleCount  ([First name])` | 1，因为 First name 中有 1 个选择项 John。 |
| 假定选择 Peter（在 First name 中）。<br><br>`GetPossibleCount  ([Initials])` | 2，因为 Peter 与 Initials 中的 2 个值关联。 |
| 假定未在 First name 中选择任何值。<br><br>`GetPossibleCount  ([First name])` | 5，因为没有选择项，并且 First name 中有 5 个唯一的值。 |
| 假定未在 First name 中选择任何值。<br><br>`GetPossibleCount  ([Initials])` | 6，因为没有选择项，并且 Initials 中有 6 个唯一的值。 |

示例中所使用的数据：

```
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 '|');
```