Calculate computed column in flux and store it in Variable and use this variable in visualization

Basically we’re integrating InfluxDB and Grafana in our work. We’re using InfluxDB as database source, and producing visualizations in Grafana. Is it possible to query the product of Voltage and Current directly in Grafana dashboard? How do we get to the energy from power in Grafana dashboard? Any help is highly appreciated.
collectionInterval = 5m

from(bucket: “Grafana_Bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == “19042023_V24_City_1R_ECO_sathish_battery_switch_test_new” and
(r._field == “BF_CellVoltage1” or r._field == “BMSF_ChargingCurrent”)
)
|> map(fn: (r) => ({ r with power: r.BF_CellVoltage1 * r.BMSF_ChargingCurrent }))
|> integral(unit: collectionInterval, column: “power”)
|> rename(columns: { power: “energy” })
|> aggregateWindow(every: 1d, fn: sum, column: “energy”)
.Please help me to find solution
i am trying to execute this query in grafana but even getting error like Power Does Not exist

Hello @nagashree,
does any part of your query work?
Where is it failing? At the integral function?
Or at the rename function?

Could you share the output after the integral function?

Is it possible you’re missing a capital or something?

Hi @Anaisdg
Thanks for your Response. I was failed to execute this query because i have not called Pivot() .now it is working fine