> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# coll.frequencies

> Counts the frequency of each element in a list, returning a map of elements to their occurrence counts.

## Description

Counts the frequency of each element in a list, returning a map where keys are the unique elements and values are their occurrence counts.

## Syntax

```cypher theme={null}
flex.coll.frequencies(list)
```

## Parameters

| Parameter | Type | Required | Description         |
| --------- | ---- | -------- | ------------------- |
| `list`    | list | Yes      | The list to analyze |

## Returns

**Type:** map (object)

A map where each key is a unique element from the list and each value is the count of how many times that element appears. Returns an empty map if input is not an array.

## Examples

### Example 1: Basic Frequency Count

```cypher theme={null}
WITH ['apple', 'banana', 'apple', 'cherry', 'banana', 'apple'] AS fruits
RETURN flex.coll.frequencies(fruits) AS counts
```

**Output:**

```text theme={null}
counts
---------------------------------------
{apple: 3, banana: 2, cherry: 1}
```

### Example 2: Tag Analysis

```cypher theme={null}
MATCH (d:Document)
WITH collect(d.tags) AS allTagLists
UNWIND allTagLists AS tags
UNWIND tags AS tag
WITH collect(tag) AS flatTags
RETURN flex.coll.frequencies(flatTags) AS tagCounts
```

### Example 3: Finding Most Common Values

```cypher theme={null}
MATCH (u:User)
WITH collect(u.country) AS countries
WITH flex.coll.frequencies(countries) AS freq
UNWIND keys(freq) AS country
RETURN country, freq[country] AS count
ORDER BY count DESC
LIMIT 10
```

### Example 4: Word Frequency Analysis

```cypher theme={null}
MATCH (doc:Document)
WITH split(toLower(doc.content), ' ') AS words
WITH flex.coll.frequencies(words) AS wordCounts
UNWIND keys(wordCounts) AS word
WHERE wordCounts[word] > 5
RETURN word, wordCounts[word] AS frequency
ORDER BY frequency DESC
```

## Notes

* Returns empty map if input is not an array or is `null`
* `null` and `undefined` values are stored with key `"null"`
* All elements are converted to string keys in the result map
* Useful for analytics, statistics, and data exploration
* Can be combined with `keys()` and sorting for top-N analysis

## See Also

* [coll.union](/udfs/flex/collections/union) - Get unique elements (keys would give unique items)
* [coll.intersection](/udfs/flex/collections/intersection) - Find common elements

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What does flex.coll.frequencies return?">
    It returns a map where each key is a unique element from the input list and each value is the number of times that element appears.
  </Accordion>

  <Accordion title="Can I use frequencies with non-string elements?">
    Yes. The function works with any comparable data types including strings, numbers, and booleans.
  </Accordion>
</AccordionGroup>
