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!