---
title: v1.fieldsAsCols() function
description: v1.fieldsAsCols() is a special application of pivot() that pivots input data on _field and _time columns to align fields within each input table that have the same timestamp.
url: https://docs.influxdata.com/flux/v0/stdlib/influxdata/influxdb/v1/fieldsascols/
estimated_tokens: 754
product: InfluxDB OSS v1
version: v1
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/influxdata/influxdb/v1/fieldsascols/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.16.0 – 0.88.0

InfluxDB support

`v1.fieldsAsCols()` is a special application of `pivot()` that pivots input data
on `_field` and `_time` columns to align fields within each input table that
have the same timestamp.

#### Deprecated

See influxdata/influxdata/schema.fieldsAsCols.

##### Function type signature

```js
(<-tables: stream[A]) => stream[B] where A: Record, B: Record
```

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

## Parameters

### tables

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

## Examples

### Pivot InfluxDB fields into columns

```js
import "influxdata/influxdb/v1"

data
    |> v1.fieldsAsCols()
```

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

View example input and output

#### Input data

|       \_time       |\*\_measurement| \*loc |\*\_field|\_value|
|--------------------|---------------|-------|---------|-------|
|2021-01-01T12:00:00Z|       m       |Seattle|   hum   | 89.2  |
|2021-01-02T12:00:00Z|       m       |Seattle|   hum   | 90.5  |
|2021-01-03T12:00:00Z|       m       |Seattle|   hum   | 81.0  |

|       \_time       |\*\_measurement| \*loc |\*\_field|\_value|
|--------------------|---------------|-------|---------|-------|
|2021-01-01T12:00:00Z|       m       |Seattle|  temp   | 73.1  |
|2021-01-02T12:00:00Z|       m       |Seattle|  temp   | 68.2  |
|2021-01-03T12:00:00Z|       m       |Seattle|  temp   | 61.4  |

#### Output data

|       \_time       |\*\_measurement| \*loc |hum |temp|
|--------------------|---------------|-------|----|----|
|2021-01-01T12:00:00Z|       m       |Seattle|89.2|73.1|
|2021-01-02T12:00:00Z|       m       |Seattle|90.5|68.2|
|2021-01-03T12:00:00Z|       m       |Seattle|81.0|61.4|

#### Deprecated

`v1.fieldsAsCols()` was deprecated in **Flux v0.88.0** in favor of[`schema.fieldsAsCols()`](/flux/v0/stdlib/influxdata/influxdb/schema/fieldsascols/).

#### Not supported in the Flux REPL

`v1` functions can retrieve schema information when executed within
the context of InfluxDB, but not from the [Flux REPL](/influxdb/cloud/tools/repl/).

[transformations](/flux/v0/tags/transformations/)
| _time | *_measurement | *loc | *_field | _value |
| --- | --- | --- | --- | --- |
| _time | *_measurement | *loc | *_field | _value |
| 2021-01-01T12:00:00Z | m | Seattle | hum | 89.2 |
| 2021-01-02T12:00:00Z | m | Seattle | hum | 90.5 |
| 2021-01-03T12:00:00Z | m | Seattle | hum | 81.0 |

| _time | *_measurement | *loc | *_field | _value |
| --- | --- | --- | --- | --- |
| _time | *_measurement | *loc | *_field | _value |
| 2021-01-01T12:00:00Z | m | Seattle | temp | 73.1 |
| 2021-01-02T12:00:00Z | m | Seattle | temp | 68.2 |
| 2021-01-03T12:00:00Z | m | Seattle | temp | 61.4 |

| _time | *_measurement | *loc | hum | temp |
| --- | --- | --- | --- | --- |
| _time | *_measurement | *loc | hum | temp |
| 2021-01-01T12:00:00Z | m | Seattle | 89.2 | 73.1 |
| 2021-01-02T12:00:00Z | m | Seattle | 90.5 | 68.2 |
| 2021-01-03T12:00:00Z | m | Seattle | 81.0 | 61.4 |
