---
title: contains() function
description: contains() tests if an array contains a specified value and returns true or false.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/contains/
estimated_tokens: 1595
product: Flux
version: v0
---

# contains() function

-   Flux 0.19.0+
-   View InfluxDB support

`contains()` tests if an array contains a specified value and returns `true` or `false`.

##### Function type signature

```js
(set: [A], value: A) => bool where A: Nullable
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### value

(Required) Value to search for.

### set

(Required) Array to search.

## Examples

### Filter on a set of specific fields

```js
fields = ["f1", "f2"]

data
    |> filter(fn: (r) => contains(value: r._field, set: fields))
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 | f1 | m |
| 2021-01-01T00:00:50Z | 4 | t1 | f1 | m |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 4 | t2 | m | f1 |
| 2021-01-01T00:00:20Z | -3 | t2 | m | f1 |
| 2021-01-01T00:00:50Z | 1 | t2 | m | f1 |

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 10 | t1 | f2 | m |
| 2021-01-01T00:00:20Z | 7 | t1 | f2 | m |

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:30Z | 17 | t1 | f3 | m |
| 2021-01-01T00:00:40Z | 15 | t1 | f3 | m |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 | m | f3 |
| 2021-01-01T00:00:30Z | 19 | t2 | m | f3 |
| 2021-01-01T00:00:40Z | 13 | t2 | m | f3 |

#### Output data

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 | f1 | m |
| 2021-01-01T00:00:50Z | 4 | t1 | f1 | m |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |

| _time | _value | *tag | _measurement | *_field |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 4 | t2 | m | f1 |
| 2021-01-01T00:00:20Z | -3 | t2 | m | f1 |
| 2021-01-01T00:00:50Z | 1 | t2 | m | f1 |

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |

| _time | _value | *tag | *_field | _measurement |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 10 | t1 | f2 | m |
| 2021-01-01T00:00:20Z | 7 | t1 | f2 | m |

#### Related

-   [Work with arrays](/flux/v0/data-types/composite/array/)
