Documentation

Use values to calculate a new column

This example uses NOAA water sample data.

This example converts temperature from Fahrenheit to Celsius and maps the Celsius value to a new celsius column.

The following query: - Uses filter() to filter the average_temperature measurement. - Uses map() to create a new column calculated from existing values in each row.

from(bucket: "noaa")
  |> filter(fn: (r) => r._measurement == "average_temperature")
  |> map(fn: (r) => ({r with
      celsius: ((r._value - 32.0) * 5.0 / 9.0)
    })
  )

Example results

_start_stop_field_measurementlocation_time_valuecelsius
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:00:00Z8227.78
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:06:00Z7322.78
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:12:00Z8630.00
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:18:00Z8931.67
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:24:00Z7725.00
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:30:00Z7021.11
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:36:00Z8428.89
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:42:00Z7624.44
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:48:00Z8529.44
1920-03-05T22:10:01Z2020-03-05T22:10:01Zdegreesaverage_temperaturecoyote_creek2019-08-17T00:54:00Z8026.67
••••••••••••••••••••••••

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: