Hello @hermann4,

Is your data in two tables? Can you share the query you use to get those speed and brake values so I can get a better feel for your schema?

Can you not apply the sum() function?

https://docs.influxdata.com/influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/sum/

```
sum(column: "break")
```

If your data is in multiple tables, you might have to apply a `group()`

function first to ungroup your data so you can sum across tables.

If you need to group by speed value you can use conditional query logic to apply a tag like so:

https://docs.influxdata.com/influxdb/cloud/query-data/flux/conditional-logic/

```
import "influxdata/influxdb/schema"
from(bucket: "my bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "my measurement")
|> filter(fn: (r) => r["_field"] == "speed")
|> map(fn: (r) => ({
r with
speed_level:
if r._value >= 20.0 and r._value <= 30.0 then "20-30"
else if r._value >= 30.0 and r._value <= 40.0 then "30-40"
else "other speed"
})
)
|> group(columns: [speed_level"], mode:"by")
|> schema.fieldsAsCols()
|> sum(column: "break")
// this query will give you a separate table where each table is the sum for the range of speeds. if you wanted total sum from here you could group() and sum again.
```

I’m using the schema.fieldsAsCols() function to pivot the data so that I can get two columns with the values for the speed and the break. This might be all your asking for if your data is all in one table and you don’t want to perform any sort of speed range tagging.

https://docs.influxdata.com/influxdb/cloud/reference/flux/stdlib/influxdb-schema/fieldsascols/