---
title: "cardinality function in Strata | Oplema"
description: "Count the entries in a map, returning the map's size as a number. For example, cardinality(map([4, 2], ['a', 'b'])) returns 2."
url: "https://oplema.com/docs/strata/functions/cardinality"
updated: "2026-11-04"
---

# cardinality

Count the entries in a map.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
cardinality(map([4, 2], ['a', 'b']))
```

### Result

```
'2'
```

The expression returns `UBIGINT`. Formula stores it as `VARCHAR` in this example. To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 2 |

## Arguments and types

```
cardinality(map, ...)
```

**map**

Any value

Supported signatures (1)

```
cardinality(map: ANY, ...: ANY) → UBIGINT
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[map\_entries

Return a map's entries as a list of structs with key and value fields.

](https://oplema.com/docs/strata/functions/map-entries)[map\_from\_entries

Create a map from a list of structs that each hold a key and a value.

](https://oplema.com/docs/strata/functions/map-from-entries)[element\_at

Look up a key in a map and return its value inside a list, or an empty list if the key is absent. The key must have the same type as the map's keys.

](https://oplema.com/docs/strata/functions/element-at)[map\_concat

Merge maps into one. If a key appears more than once, the value from the last map with that key wins.

](https://oplema.com/docs/strata/functions/map-concat)

[Browse maps](https://oplema.com/docs/strata/functions#maps) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/map.html#cardinalitymap)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
