---
url: /cube-functions/occurrences.md
description: Returns the count of occurrences of the needle in the haystack.
---

# OCCURRENCES

Returns the count of occurrences of the needle in the haystack. This function is case sensitive.

```js
OCCURRENCES(haystack, needle)
```

#### Parameters

* `haystack` - The string input (the haystack).
* `needle` - The string to be found (the needle).

#### Examples

```js
OCCURRENCES("ABCDEFG ABC", "B")
```

**Result:** `2`
