# SubStringCount - script and chart function

SubStringCount() returns the number of occurrences of the specified substring in the input string text. If there is no match, 0 is returned.

Syntax:

SubStringCount(text, sub\_string)

Return data type: integer

Arguments:

| Argument | Description |
| --- | --- |
| text | The original string. |
| sub\_string | A string which<br>may occur one or more times within the input string text. |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/SubStringCount.htm)

#### Example: Chart expressions

| Example | Result |
| --- | --- |
| `SubStringCount<br>( 'abcdefgcdxyz', 'cd' )` | Returns '2' |
| `SubStringCount<br>( 'abcdefgcdxyz', 'dc' )` | Returns '0' |

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/StringFunctions/SubStringCount.htm)

#### Example: Load script

```
T1:
Load *, 
substringcount(upper(Strings),'AB') as SubStringCount_AB;
Load * inline [
Strings
ABC:DEF:GHI:AB:CD:EF:GH
aB/cd/ef/gh/Abc/abandoned ]; 
```

Result

| Strings | SubStringCount\_AB |
| --- | --- |
| aB/cd/ef/gh/Abc/abandoned | 3 |
| ABC:DEF:GHI:AB:CD:EF:GH | 2 |