# GetAlternativeCount

GetAlternativeCount() is used to find the number of alternative (white cell with gray text) values in the identified field.

Syntax:

GetAlternativeCount (field\_name)

**Return data type:** integer

Arguments:

* field\_name: The field containing the range of data to be measured.

## Color of selection states in List Boxes

All information on this page refers to the color of selection states in a List Box with specific settings:

* The QlikView document configured to a Color Scheme of Classic Extended. See: [Selection Appearance](https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/Document_Properties_General.htm#SelectionAppearance)

* List Box configured with Show Alternatives turned on. See: [Show Alternatives](https://help.qlik.com/en-US/qlikview/May2024/Subsystems/Client/Content/QV_QlikView/List_Box.htm#ShowAlternatives)

The following table outlines the color scheme for each selection state in a List Box with this configuration.

Color scheme for List box with given configuration

| State | Cell color | Text color |
| --- | --- | --- |
| Alternative | White | Gray |
| Deselected | Red | Black |
| Excluded | Gray | White |
| Possible | White | Black |
| Selected | Green | Black |
| Selected excluded | Gray | Green |

## Examples

The following examples use the First name field loaded to a list box, and the following syntax:

`GetAlternativeCount  ([First name])`

* Given that John is selected in First name, the script returns 4 as there are 4 unique and excluded (gray) values in First name.
* Given that John and Peter are selected, the script returns 3 as there are 3 unique and excluded (gray) values in First name.
* Given that no values are selected in First name, the script returns 0 as there are no selections.

Data used in example:

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