# GetSelectedCount - chart function

GetSelectedCount() finds the number of selected (green) values in a field.

[Using Calculation Conditions](https://play.vidyard.com/UDRXiPe6LFDgdePb4CuF3L)

Syntax:

GetSelectedCount (field\_name [, include\_excluded [, state\_name]])

Return data type: integer

Information note

The colors used in the selection bar, and for each selection state, can be modified with a custom theme. If you are working with an app that uses a custom theme, you might notice that your selections do not display with the same colors that are described in this help topic.

Arguments:

Arguments

| Arguments | Description |
| --- | --- |
| field\_name | The field containing the range of data to be measured. |
| include\_excluded | If set to True(), the count will include selected values, which are currently excluded by<br>selections in other fields. If False or omitted, these values will not be included. |
| state\_name | The name of an alternate state that has been chosen for the specific visualization. If the state\_name argument is used, only the selections associated with the specified state name are taken into account.<br><br>For more information, see [Using alternate states for comparative analysis](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/Visualizations/alternate-states-comparative-analysis.htm). |

The following table lists other functions that are related to this function.

Related functions

| Function | Interaction |
| --- | --- |
| [GetStateCounts - chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getstatecounts.htm) | Using GetStateCounts(), you can combine the calculation of the following counts using a single function call:<br><br><ul> <li> <p>Count of selected included values.</p> </li> <li> <p>Count of possible values.</p> </li> <li> <p>Count of alternative values.</p> </li> <li> <p>Count of excluded values, not including alternative and selected excluded values.</p> </li> <li> <p>Count of selected excluded values.</p> </li> </ul> |
| [GetPossibleCount - chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getpossiblecount.htm) | Returns the count of possible values. |
| [GetAlternativeCount - chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getalternativecount.htm) | Returns the count of alternative values. |
| [GetSelectedCount - chart function](https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/FieldFunctions/getselectedcount.htm#) | Returns the count of excluded values, not including alternative and selected excluded values. |

Examples and results:

The following example uses three fields loaded to different filter panes, one for First name name, one for Initials and one for Has cellphone.

Examples and results

| Examples | Results |
| --- | --- |
| Given that John is selected in First name.<br><br>`GetSelectedCount  ([First name])` | 1 as one value is selected in First name. |
| Given that John is selected in First name.<br><br>`GetSelectedCount  ([Initials])` | 0 as no values are selected in Initials. |
| With no selections in First name, select all values in Initials and after that select the value Yes in Has cellphone.<br><br>`GetSelectedCount  ([Initials], True())` | 6. Although selections with Initials values of MC and PD have Has cellphone set to No, the result is still 6, because the argument `include_excluded` is set to `True()`. |

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