How do I use data from another query as a multiplier?

I have a full query where I am using the constant 1925.25 as a placeholder for what should be a variable (since it is the value of ETH/USD). My current query is this:

from(bucket: "Mining")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "Miner")
  |> filter(fn: (r) => r["_field"] == "balance")
  |> filter(fn: (r) => r["tag1"] == "ethermine")
  |> map(fn: (r) => ({r with _value: (float(v: r._value) / 1000000000000000000.0) * 1925.25 }))
  |> aggregateWindow(every: 1h, fn: last)
  |> derivative(unit: 1h, nonNegative: true, columns: ["_value"])
  |> cumulativeSum(columns: ["_value"])

What I would like to do is use this data variable in place of the 1925.25, but I can’t figure out how to do that:

data = from(bucket: "Mining")
  |> range(start: -10m)
  |> filter(fn: (r) => r._measurement == "Miner")
  |> filter(fn: (r) => r.tag1 == "flexpool")
  |> filter(fn: (r) => r._field == "price")
  |> last()

data

How would I use that in a single query so that I am getting the latest value for “price” for multiplication in the calculation above?

Both of the queries work fine and return what is expecetd in InfluxDB2 Data Explorer (FYI)

Thanks!

Still trying to do this and haven’t figured it out :frowning: Tried so many things, but keep giving up.

I’m still learning influxdb2 myself, and there’s some rough edges no doubt.

At a guess, the issue might be that data variable is still a “table” with start /end times and column names, instead of a single value / scalar.

Can you flip the explorer into raw mode (should be a toggle near the run query button) and the paste the output from data variable .