Basic Math failing to yield expected results

  • What Grafana version and what operating system are you using?
    Grafana 9.0.3 in Home Assistant with Influx DB

  • What are you trying to achieve?
    Multiply the results of two queries

  • How are you trying to achieve it?
    Using a Regular Expression

  • What happened?
    The result is unexpected from the data 17.9 * 0.195 = 3.04

  • What did you expect to happen?
    An accurate result would be 3.49

  • Can you copy/paste the configuration(s) that you are having problems with?
    Query A:
    SELECT last(“value”) FROM “autogen”.“kWh” WHERE (“entity_id”::tag = ‘octopus_energy_electricity_20j0027278_1413218722007_previous_accumulative_consumption’) AND $timeFilter GROUP BY time(24h) fill(null)

Query B:
SELECT last(“value”) FROM “autogen”.“GBP/kWh” WHERE (“entity_id”::tag = ‘octopus_energy_electricity_20j0027278_1413218722007_previous_rate’) AND $timeFilter GROUP BY time(24h) fill(null)

Expression Operation: Math $A * $B

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

Write expression queries | Grafana documentation