How to Multiply the result with Constant ( flux query)

I need to multiply the result of the below program with a constant ( 0.1135). How to do that? Thanks in Advance!

from(bucket: “ABC”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “DentMeter”)
|> filter(fn: (r) => r[“_field”] == “BRPumpsKWH” or r[“_field”] == “ChillersKWH” or r[“_field”] == “HousePanelKWH”)
|> spread()
|> group()
|> sum()

Hi @Bharath
Perhaps you can make use of the map() function:

from(bucket: “ABC”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “DentMeter”)
|> filter(fn: (r) => r[“_field”] == “BRPumpsKWH” or r[“_field”] == “ChillersKWH” or r[“_field”] == “HousePanelKWH”)
|> spread()
|> group()
|> sum()
 |> map(fn: (r) => ({ r with _value: r._value * 0.1135 }))
1 Like

Thank you so much Jay. It is working and very helpful.

Hey Jay When I use the above code, there is an issue because of the use case. if I use the spread(), It was taking the last value and subtracts the first value.

But the use case is sometimes the Meter Reading will reset to Zero due to maintenance or power issue. In that case, the Spread() function will give the wrong value.

So I am trying to totalize the values, Like finding only the Positive difference between two consecutive records and totalizing it to find the correct consumption.

Is there any function for this? Thanks!

Bharath

@Anaisdg do you have any ideas on how we can achieve this one?