I can sum the value of all datapoints in the current timeframe when there is just one data source, but…
I’d like to sum the total value of all datapoints in the current timeframe when there are numerous data sources.
Example, you want to calculate the total interest ££s from 5 savings accounts.
You have 5 data sources from the same influx bucket which report their daily interest amount daily, and you have the absolute time frame set to the current fiscal year.
To calculate the total savings return, you would need to add all of the 365 datapoints from each of the data sources, and display it in a stat widget.
Just to make an assumption about your data, when you say “5 data sources from the same Influx bucket”, you mean 5 measurements? If yes, try something like this:
from(bucket: "your_bucket")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop) // this will get overridden by your absolute time frame in Grafana
|> filter(fn: (r) => r["_measurement"] == "savings1" or r["_measurement"] == "savings2" or r["_measurement"] == "savings3" etc. etc. ) // you could also use regex here if you have tons of savings accounts
|> group(columns: ["_time"])
|> sum(column: "interest") // or just sum() if your interest is in a column called "_value"
|> yield(name: "total_interest")