---
title: keyValues() function
description: keyValues() returns a stream of tables with each input tables’ group key and two columns, _key and _value, that correspond to unique column label and value pairs for each input table.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/keyvalues/
estimated_tokens: 1645
product: Flux
version: v0
---

# keyValues() function

-   Flux 0.13.0+
-   View InfluxDB support

`keyValues()` returns a stream of tables with each input tables’ group key and two columns, \_key and \_value, that correspond to unique column label and value pairs for each input table.

##### Function type signature

```js
(<-tables: stream[A], ?keyColumns: [string]) => stream[{B with _value: C, _key: string}] where A: Record, B: Record
```

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

## Parameters

### keyColumns

List of columns from which values are extracted.

All columns must be of the same type. Each input table must have all of the columns in the `keyColumns` parameter.

### tables

Input data. Default is piped-forward data (`<-`).

## Examples

### Get key values from explicitly defined columns

```js
data
    |> keyValues(keyColumns: ["sensorID", "_field"])
```

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

View example input and output

#### Input data

| *_field | *_measurement | *sensorID | _time | _value |
| --- | --- | --- | --- | --- |
| co | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 0.31 |
| co | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 0.295 |
| co | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 0.314 |
| co | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 0.313 |

| *_field | *_measurement | *sensorID | _time | _value |
| --- | --- | --- | --- | --- |
| humidity | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 36.03 |
| humidity | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 36.07 |
| humidity | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 36.1 |
| humidity | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 36.12 |

| *_field | *_measurement | *sensorID | _time | _value |
| --- | --- | --- | --- | --- |
| temperature | airSensors | TLM0100 | 2021-09-08T14:21:57Z | 70.84 |
| temperature | airSensors | TLM0100 | 2021-09-08T14:22:07Z | 70.86 |
| temperature | airSensors | TLM0100 | 2021-09-08T14:22:17Z | 70.89 |
| temperature | airSensors | TLM0100 | 2021-09-08T14:22:27Z | 70.85 |

#### Output data

| *_field | *_measurement | *sensorID | _key | _value |
| --- | --- | --- | --- | --- |
| co | airSensors | TLM0100 | sensorID | TLM0100 |
| co | airSensors | TLM0100 | _field | co |

| *_field | *_measurement | *sensorID | _key | _value |
| --- | --- | --- | --- | --- |
| humidity | airSensors | TLM0100 | sensorID | TLM0100 |
| humidity | airSensors | TLM0100 | _field | humidity |

| *_field | *_measurement | *sensorID | _key | _value |
| --- | --- | --- | --- | --- |
| temperature | airSensors | TLM0100 | sensorID | TLM0100 |
| temperature | airSensors | TLM0100 | _field | temperature |

#### Related

-   [InfluxQL – SHOW MEASUREMENTS](/influxdb/v1/query_language/explore-schema/#show-measurements)
-   [InfluxQL – SHOW FIELD KEYS](/influxdb/v1/query_language/explore-schema/#show-field-keys)
-   [InfluxQL – SHOW TAG KEYS](/influxdb/v1/query_language/explore-schema/#show-tag-keys)
-   [InfluxQL – SHOW TAG VALUES](/influxdb/v1/query_language/explore-schema/#show-tag-values)
-   [InfluxQL – SHOW SERIES](/influxdb/v1/query_language/explore-schema/#show-serie)

[transformations](/flux/v0/tags/transformations/)
