---
title: tickscript.select() function
description: tickscript.select() changes a column’s name and optionally applies an aggregate or selector function to values in the column.
url: https://docs.influxdata.com/flux/v0/stdlib/contrib/bonitoo-io/tickscript/select/
estimated_tokens: 3071
product: Flux
version: v0
---

# tickscript.select() function

-   Flux 0.111.0+
-   View InfluxDB support

`tickscript.select()` is a user-contributed function maintained by the [package author](#package-author-and-maintainer).

`tickscript.select()` changes a column’s name and optionally applies an aggregate or selector function to values in the column.

## TICKscript helper function

`tickscript.select()` is a helper function meant to replicate TICKscript operations like the following:

```
// Rename
query("SELECT x AS y")

// Aggregate and rename
query("SELECT f(x) AS y")
```

##### Function type signature

```js
(<-tables: B, as: string, ?column: A, ?fn: (<-: B, column: A) => stream[C]) => stream[D] where A: Equatable, C: Record, D: Record
```

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

## Parameters

### column

Column to operate on. Default is `_value`.

### fn

Aggregate or selector function to apply.

### as

(Required) New column name.

### tables

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

## Examples

-   [Change the name of the value column](#change-the-name-of-the-value-column)
-   [Change the name of the value column and apply an aggregate function](#change-the-name-of-the-value-column-and-apply-an-aggregate-function)
-   [Change the name of the value column and apply a selector function](#change-the-name-of-the-value-column-and-apply-a-selector-function)

### Change the name of the value column

```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
    |> tickscript.select(as: "example-name")
```

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

View example input and output

#### Input data

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| _time | example-name | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | example-name | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

### Change the name of the value column and apply an aggregate function

```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
    |> tickscript.select(as: "sum", fn: sum)
```

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

View example input and output

#### Input data

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| *tag | sum |
| --- | --- |
| t1 | 51 |

| *tag | sum |
| --- | --- |
| t2 | 53 |

### Change the name of the value column and apply a selector function

```js
import "contrib/bonitoo-io/tickscript"
import "sampledata"

sampledata.int()
    |> tickscript.select(as: "max", fn: max)
```

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

View example input and output

#### Input data

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| _time | max | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:30Z | 17 | t1 |

| _time | max | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |

#### Related

-   [tickscript.selectWindow() function](/flux/v0/stdlib/contrib/bonitoo-io/tickscript/selectwindow/)

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