How to output multiple fields in a task

Hi All, can someone give me an example of output multiple fields in a task? I’m wanting to aggregate 1 min tick date (open, high, low, close) into 15 min bins.

Thanks in advance

Hello @Lokke,
Welcome! Have you had a chance to look at this documentation?
Or this example?:

// Task options
option task = {
    name: "cqinterval15m",
    every: 1h,
    offset: 0m,
    concurrency: 1,
    retry: 5
}

// Data source
data = from(bucket: "telegraf/default")
  |> range(start: -task.every)
  |> filter(fn: (r) =>
    r._measurement == "mem" and
    r.host == "myHost"
  )

data
  // Data transformation
  |> aggregateWindow(
    every: 5m,
    fn: mean
  )
  // Data destination
  |> to(bucket: "telegraf_downsampled")

In this example, several fields are being aggregated. I recommend taking a look at what your data transformation will look like in the data explorer before running a task to make sure you’re getting what you expect.

If you’re still having trouble, can you please share some input data, your task, and your expected output?

Thank you

Thanks, guess I didn’t make it clear.

In v1.7, I could put many per field function here. E.g sum(volume), first(open), …
I tried something like this:
|> filter(fn: ® => r._measurement == “5m”)
|> filter(fn: ® => r._field == “volume”)
|> filter(fn: ® => r.source == “post_pull”)
|> aggregateWindow(every: 15m, fn: sum)
|> yield(name: “sum”)
|> filter(fn: ® => r._field == “open”)
|> filter(fn: ® => r.source == “post_pull”)
|> aggregateWindow(every: 15m, fn: first)
|> yield(name: “open”)
not working. Or do I have to create multiple pipelines for such tasks?

Hello @Lokke,
Thank you for clarifying. If you’re wanting to apply different aggregates to different fields, then you need to create another task.
If you wanted to apply the same data transformation to multiple fields like:
|> filter(fn: ® => r._measurement == “5m”)
|> filter(fn: ® => r._field == “volume” and r._field == “open”)
|> filter(fn: ® => r.source == “post_pull”)
|> aggregateWindow(every: 15m, fn: sum)
|> yield(name: “sum”)
then you could do that in the same task. Does that help answer your question?