Extract single value from JSON structure in measure

Hey there,
I tried to search a similar topic, but not successfully. If I just missed a topic, please let me know.

I got a measure containing a JSON structure with different measures / values. I’m able to extract fields from json in grafana to display the different values, but then I’m not able to process these values or make any calculations.
Is it possible to extract just one value from the structure, ignore all other values and use integral calculation with this data?
When using

from(bucket: “Solar”)
|> range(start: -24h)
|> filter(fn: (r) => r[“_measurement”] == “mqtt.1.XXXXXXX.state”)
|> filter(fn: (r) => r[“_field”] == “value”)

I get the following output for every point in time:

{
“id”: 0,
“a_current”: 0.619,
“a_voltage”: 234.5,
“a_act_power”: 94,
“a_aprt_power”: 145.4,
“a_pf”: 0.66,
“a_freq”: 50,
“b_current”: 0.368,
“b_voltage”: 235.2,
“b_act_power”: 57.4,
“b_aprt_power”: 86.6,
“b_pf”: 0.67,
“b_freq”: 50,
“c_current”: 0.923,
“c_voltage”: 232.6,
“c_act_power”: -115.4,
“c_aprt_power”: 214.4,
“c_pf”: 0.56,
“c_freq”: 50,
“n_current”: null,
“total_current”: 1.909,
“total_act_power”: 36.034,
“total_aprt_power”: 446.27,
“user_calibrated_phase”: “”
}

How can I just pick for example c_act_power and use this column/value for further calculations?

Thanks and best regards

Hello @Steeed,
is your field value in fact a json? Or do you just want to use a specific value?

import "experimental/json"
import "array"

data = array.from(rows: [{_value: 2}])


record = data
    |> findRecord(
        fn: (key) => true,
        idx: 0,
    )// Returns { _value: 2}

array.from(rows: [{_value: record._value + 2}])
// |> yield(name: "result returned with calculation") //returns a table with 4 

and then you can apply that to: