> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Bitmap or Aggregate calculations from a unsigned integer column, return cardinality of type UInt64, if add suffix -State, then return a bitmap object

# groupBitmap

<h2 id="groupBitmap">
  groupBitmap
</h2>

Introduced in: v20.1.0

Creates a bitmap (bit array) from a column of unsigned integers, then returns the count of unique values (cardinality) in that bitmap.
By appending the `-State` combinator suffix, instead of returning the count, it returns the actual [bitmap object](/reference/functions/regular-functions/bitmap-functions).

**Syntax**

```sql theme={null}
groupBitmap(expr)
groupBitmapState(expr)
```

**Arguments**

* `expr` — Expression that results in a `UInt*` type. [`UInt*`](/reference/data-types/int-uint)

**Returned value**

Returns the count of type UInt64 type, or a bitmap object when using `-State`. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
CREATE TABLE t (UserID UInt32) ENGINE = Memory;
INSERT INTO t VALUES (1), (1), (2), (3);

SELECT groupBitmap(UserID) AS num FROM t;
```

```response title=Response theme={null}
┌─num─┐
│   3 │
└─────┘
```
