Exclude (querying) values below a certain threshold for average calculation

  • What Grafana version and what operating system are you using?
    Grafana v8.3.4

  • What are you trying to achieve?

We have two different systems/databases (with slightly different configurations) which log the number of traffic jams for a city over time. Every 20 seconds the ratio (number of jams in system 1 divided by number of jams in system 2) is calculated and stored. When selecting a 24 hours time range in the upper right corner, the Grafana dashboard is showing the 24h average value of all stored ratios between both systems

However, since there are only a few (up to zero) traffic jams present during nighttime, we would like to exclude querying values from systems if the jam counts in one (or both) system(s) are below a certain threshold (e.g. 50), so they are not included for the overall 24h average calculation. No ratio should be stored in such cases.

Currently the nighttime ratios are equally weighted as the daytime ratios. Furthermore, if one of the system is going down to 0 jams, we get a divide by 0 error, resulting in an infinite average value for the 24h calculation.

Is there any chance to do this? Any help is highly appreciated :slight_smile: Thanks a lot!

hello, what is your data source ?

we would like to exclude querying values from systems if the jam counts in one (or both) system(s) are below a certain threshold (e.g. 50)

look like you found your solution, make condition to exclude 0 value or fill it with null or something don’t break easily
Do you need help on query ?