Stat panel with calculation displays incorrect value

I have a stat panel with two queries. query 1 calculates the number of records that meet a certain condition. query 2 calculates the total number of records. It also has a transform which calculates query1 as fraction of query 2.

Let’s say my time range is set to the last 15 minutes, and the last occurrence of the condition for query 1 is more than 15 minutes ago (meaning the query 1 resultant time series is empty), Grafana displays the result of query 2 as the value of the stat panel, instead of 0.

I’m not sure if this is a bug, and if so, in which component?

I’ve managed to get around the issue by adjusting the Relative time of the 1st query to a longer timeframe in which it is always guaranteed to generate a timeseries result, but is this the only solution? Am I wrong to expect a zero value in this case?

we would have to see the query 2 especially. and if you could provide some sample data it would help us help you


type of stuff

1 Like

This is the JSON from the Query Inspector.


Query 1 has no results
Query 2 has two rows

Result of panel is 6900%, the count of 2nd query


Unit of panel is set to Percent (0.0-1.0)

Calculation in transform:

This is what the CSV looks like:
“Time”,“enrollment count”
2022-05-17 10:50:00,6900%