How to calculate percentage given a condition

I’m using influxdb in Grafana, I need to calculate the percentage that a measure’s value pass between the given limits. For example: How much time did “Vapor Escape” been between 1.5 and 1.8.

For now I’m using some counters that I insert through node-red to influx, but I wanted to calculate with Influx variable that’s on the left visual.

On the second Image is where I’m suposed to do the calculation, but I can’t return a percentage of the total, based on the condition

I’ve built the queries, but cant do any math calculations. Just beeing able to do A/B would solve my problem.

As you may know, you can’t join 2 queries using InfluxQL, to achieve that you got only two options:

  • Flux , if supported by your InfluxDB version (I’m not knowledgeable about it)
  • Grafana transformations (docs here )

I’ve been able to kind of emulate a Join using the “Merge” transformation (note… the “outer join” transformation is not at all an outer join).
in your case, the merge key will be only the timestamp (so both queries must have the same aggregation interval for the points to match)

here is a screenshot to give you an idea about the transformation to use, for your case you should just need the first 2

From the screenshots posted, looks like you are not using one of the latest Grafana versions, you will need to update it in order to use transformations.