# GetPossibleCount

GetPossibleCount() 用於找出指定欄位中可能值 (白色) 的數量。如果指定欄位包含選項，則也會將所選欄位 (綠色) 納入計數。

針對選項欄位，GetPossibleCount() 會傳回所選 (綠色) 欄位的數目。

**傳回資料類型：** 整數

語法：

GetPossibleCount (field\_name)

引數：

* field\_name： 包含待測量資料範圍的欄位。

下表列出了與此函數相關的其他函數。

相關函數

| 函數 | 互動 |
| --- | --- |
| [GetStateCounts](https://help.qlik.com/zh-TW/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>已取消選取的值的計數 (僅當欄位處於 and (和) 模式時才可用)。</p></li><li><p>替代值的計數。</p></li><li><p>排除值的計數，不包括替代值和所選的排除值。</p></li><li><p>所選排除值的計數。</p></li></ul> |
| [GetSelectedCount](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getselectedcount.htm) | 傳回所選包含值的計數。 |
| [GetNotSelectedCount](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/GetNotSelectedCount.htm) | 傳回已取消選取的值的計數 (僅當欄位處於 and (和) 模式時才可用)。 |
| [GetAlternativeCount](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getalternativecount.htm) | 傳回替代值的計數。 |
| [GetPossibleCount](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/ChartFunctions/FieldFunctions/getpossiblecount.htm#) | 傳回排除值的計數，不包括替代值和所選的排除值。 |

## 列表框中選取狀態的顏色

本頁所有資訊均指在具有特定設定的列表框中選取狀態的顏色：

* QlikView 文件設定為 Classic Extended 的色彩配置。請參閱： [選項外觀](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/Document_Properties_General.htm#SelectionAppearance)

* 設定為開啟顯示替代選項的列表框。請參閱： [顯示替代選項](https://help.qlik.com/zh-TW/qlikview/September2025/Subsystems/Client/Content/QV_QlikView/List_Box.htm#ShowAlternatives)

下表概述了具有此設定的列表框中每個選取狀態的色彩配置。

具有給定設定的列表框的色彩配置

| 狀態 | 儲存格色彩 | 文字色彩 |
| --- | --- | --- |
| 替代 | 白色 | 灰色 |
| 已取消選取 | 紅色 | 黑色 |
| 已排除 | 灰色 | 白色 |
| 可能 | 白色 | 黑色 |
| 已選取 | 綠色 | 黑色 |
| 已選取且已排除 | 灰色 | 綠色 |

## 範例

以下範例使用載入至不同列表框的兩個欄位，一個用於 First name 名字，另一個用於 Initials。

範例 1: 在 First name 中選取了 John

`GetPossibleCount  ([Initials])`

傳回 1，因為在 First name 中，與選項 John 相關的 Initials 中有 1 個值。

範例 2: 在 First name 中選取了 John

`GetPossibleCount  ([First name])`

傳回 1，因為在 First name 中，有 1 個選項 John。

範例 3: 在 First name 中選取了 Peter

`GetPossibleCount  ([Initials])`

傳回 2，因為 Peter 與 Initials 中的 2 個值相關。

範例 4: 未在 First name 中選取任何值

`GetPossibleCount  ([First name])`

傳回 5，因為沒有任何選項，而 First name 中有 5 個唯一值。

範例 5: 未在 First name 中選取任何值

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