---
title: "bit_position function in Strata | Oplema"
description: "Find where a substring first starts within a bitstring, counting from 1, or get 0 when it's absent. Use it in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/bit-position"
updated: "2026-11-04"
---

# bit\_position

Returns first starting index of the specified substring within bits, or zero if it isn't present. The first (leftmost) bit is indexed 1.

## Try an expression

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

### Expression

```
bit_position('010'::BITSTRING, '1110101'::BITSTRING)
```

### Result

```
4
```

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 | 4 |

## Arguments and types

```
bit_position(substring, bitstring)
```

**substring**

Bits

**bitstring**

Bits

Supported signatures (1)

```
bit_position(substring: BIT, bitstring: BIT) → INTEGER
```

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

[set\_bit

Sets the nth bit in bitstring to newvalue; the first (leftmost) bit is indexed 0. Returns a new bitstring.

](https://oplema.com/docs/strata/functions/set-bit)[get\_bit

Extracts the nth bit from bitstring; the first (leftmost) bit is indexed 0.

](https://oplema.com/docs/strata/functions/get-bit)[bitstring

Pads the bitstring until the specified length.

](https://oplema.com/docs/strata/functions/bitstring)

[Browse bits](https://oplema.com/docs/strata/functions#bits) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/bitstring.html#bit_positionsubstring-bitstring)

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