Hi,
I have a table like this in Grafana:
Machine Start Stop
Wash 2023-11-13 07:43:34 2023-11-13 17:28:34
Wash 2023-11-09 21:48:24 2023-11-10 11:53:34
Wash 2023-11-08 15:41:34 2023-11-09 15:13:33
which is generated using the following advanced query in grafana:
data = from(bucket: “Test”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “T4”)
|> filter(fn: (r) => r[“City”] == “City”)
|> filter(fn: (r) => r[“Machine”] == “Wash”)
|> filter(fn: (r) => r[“MeasurementType”] == “Step”)
|> filter(fn: (r) => r[“Position”] == “General”)
|> truncateTimeColumn(unit: 1s)
first = data
|> first()
|> set(key: “Time”, value: “Start”)
last = data
|> last()
|> set(key: “Time”, value: “Stop”)
union(tables: [first, last])
|> pivot(rowKey: [“Machine”], columnKey: [“Time”], valueColumn: “_time”)
|> keep(columns: [“Start”,“Stop”,“Machine”])
|>group()
|>sort(columns: [“Start”])
|> filter(fn: (r) => r[“Start”] != r[“Stop”])
Now i need to modify this table with a new column ElectricityConsumption. I have another query to calculate the electricity consumed over a given time.
I need to calculate power consumed for each row in the table with start and stop in the range() as the start and stop times in each row of the table and then update each row of the new column ElectricityConsumed with the value calculated.
I am newly working in Grafana. Could anyone let me know is it possible to do this in Grafana?
Thank you in advance!