# Stats not showing current values when using absolute time range

**URL:** <https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344>\
**Category:** Grafana\
**Created:** [June 22, 2021, 9:20pm UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344 "2021-06-22T21:20:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanmairep](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jeanmairep/32/17191_2.png) [@jeanmairep](https://community.grafana.com/u/jeanmairep)\
**Post date:** [June 22, 2021, 9:20pm UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/1 "2021-06-22T21:20:34Z")

</div>

Grafana version 8.0.3 , Influxdb, Linux  
I know there has already been questions about that in the past and I tried to follow them, but cannot make it work!

Hi,  
My application records voltages and other measures every second.  
The dashboard has a number of variables and panels to analyze those measures over time. All of that works great.

I am now adding a Stat panel to display the “current” measures (the latest one that is no more than a second old). It works when the dashboard uses relative time range, but when the user zooms on a time range or selects an absolute time range, the Stat panel shows the latest measure from that time range.

The Stat panel setup (new user: cannot insert \> 2 screen shots):  
Calculate / Last (non null) / Numeric Fields

The query:  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/8/7/871123085c2e1cf8ee5a472ea26f2929beeaffd8.png)

The query options:  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/4/5/455e0eb5279728f7ac63d130be3c6cadb35dedd3.png)

I have been trying a number of different values for 'Max datapoints", “Min interval” and “Relative time”, but I cannot get the panel to display the latest measure (which is a second old or less) when the user selected time range is not relative.  
I also tried with a variable (query), but there is no option to have it update every second (only on dashboard load or change of time range).

Any hint to put me in the right direction would be greatly appreciated. Thank you.  
Phil

---

<div class="post-metadata">

**Author:** ![bferdinandes](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/bferdinandes/32/16960_2.png) [@bferdinandes](https://community.grafana.com/u/bferdinandes)\
**Post date:** [June 22, 2021, 11:36pm UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/2 "2021-06-22T23:36:05Z")

</div>

you mean, you want to ‘separate’ a panel from the date selection?  
so what ever date range selected, you always want to show the LATEST (not from that date selection range) but the REAL LATEST metric

I also have the same issue if I understand you correctly  
\*which I also want to know the answer haha

but to your problem,  
my workaround is,  
gather all reports that dont use date selection  
and create a different dashboard in the same folder  
put the reports into this new dashboard  
and then disable/hide the date picker

\*which I dont think it will work well if it is just 1 stat panel… in 1 new dashboard…

---

<div class="post-metadata">

**Author:** ![jeanmairep](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jeanmairep/32/17191_2.png) [@jeanmairep](https://community.grafana.com/u/jeanmairep)\
**Post date:** [June 23, 2021, 12:10am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/3 "2021-06-23T00:10:45Z")

</div>

Thanks for your input. Yes, you are right, I want to display the **latest** metric independently from the date selection (top right of dashboard).  
This Stat panel is only a small part of the dashboard so placing it in a different dashboard would be cumbersome for the user.  
According to all the posts on the topic, it should work by using a relative time in the query options “Relative time” that overrides the Time picker. But all these posts are related to earlier versions. Maybe functionality has changed?

---

<div class="post-metadata">

**Author:** ![grant2](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/grant2/32/42281_2.png) [@grant2](https://community.grafana.com/u/grant2)\
**Post date:** [June 23, 2021, 12:12am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/4 "2021-06-23T00:12:51Z")

</div>

I was also going to ask for clarification. So for example, if you view the last 3 hours (via the drop down), you see the most current value in the Stat panel. However, if you view, for example, the data from 21-Jun-19:07:19 to 21-Jun-22:18:53, you still want to see that same most current value (let’s say from today), but instead you are seeing the value as of 21-Jun-22:18:53.

My Stat panels behave the same way, which I believe is the intended behavior.

In your query, have you considered putting the Mean() in the Select statement and the Group By statement with a time(1s), like this:  
 ![image](https://us1.discourse-cdn.com/grafana/original/3X/7/1/71ae79cae3d8a98c74237623322b9ae6c472c966.png)

---

<div class="post-metadata">

**Author:** ![bferdinandes](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/bferdinandes/32/16960_2.png) [@bferdinandes](https://community.grafana.com/u/bferdinandes)\
**Post date:** [June 23, 2021, 12:22am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/5 "2021-06-23T00:22:13Z")

</div>

not sure about previous version as I just jumped in this grafana like 2-3 weeks ago

and yes, as you mentioned, that ‘relative time’ is not working (at least for current version 8) for our issues  
that relative time will give you a shift FROM the date selection  
it doesnt really separate the panel from date selection

---

<div class="post-metadata">

**Author:** ![bferdinandes](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/bferdinandes/32/16960_2.png) [@bferdinandes](https://community.grafana.com/u/bferdinandes)\
**Post date:** [June 23, 2021, 12:24am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/6 "2021-06-23T00:24:39Z")

</div>

> [@grant2](#):
>
> I was also going to ask for clarification. So for example, if you view the last 3 hours (via the drop down), you see the most current value in the Stat panel. However, if you view, for example, the data from 21-Jun-19:07:19 to 21-Jun-22:18:53, you still want to see that same most current value (let’s say from today), but instead you are seeing the value as of 21-Jun-22:18:53.

but yes, you understand our issues correctly 🙂

not sure about the Mean() function tho…

1. mean doesnt mean latest
2. I never use that query builder in all my reports. I use ‘edit query’ option

but thanks, maybe mean could help @jeanmairep

---

<div class="post-metadata">

**Author:** ![jeanmairep](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jeanmairep/32/17191_2.png) [@jeanmairep](https://community.grafana.com/u/jeanmairep)\
**Post date:** [June 23, 2021, 12:56am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/7 "2021-06-23T00:56:11Z")

</div>

My understanding is that it did not use to work as I explained above. In this post: [Time Range -\> Override relative time - #3 by cezarolavo](https://community.grafana.com/t/time-range-override-relative-time/11721/3) @ [danielgonzalez] says: “Isn’t a bug!! Is feature!!!”

But it seems that in version 7 it became a feature as someone said it in this post: [Grafana 7 - Stat panel - Time of last point - #6 by nudelmann](https://community.grafana.com/t/grafana-7-stat-panel-time-of-last-point/30634/6) [anhhuy2591] writes: " I solved this by using Value “Last” and adding “relative time” (with value “5m” = last 5 minutes) to “Query options” since I want to display current/latest value only (_regardless the selected time frame_)."

It seems to me that at the moment, when setting a “Relative time” in the query options, it is “Relative” to the last date in the selected date range… and not to **now**.  
Not sure what the current status is for version 8: feature or bug? Would be great if someone from Grafana can set our expectations in that regard and, if it is a feature, give us details on the required setup to make it work.  
Thanks  
Phil

---

<div class="post-metadata">

**Author:** ![svetb](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/svetb/32/3307_2.png) [@svetb](https://community.grafana.com/u/svetb)\
**Post date:** [June 23, 2021, 6:21am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/8 "2021-06-23T06:21:34Z")

</div>

@jeanmairep what you’re after is actually pretty simple, at least in a sense. Firstly, you are right to observe that fiddling with the time range overrides doesn’t help - since those are always relative to the dashboard range.

But what you can do is just remove the time range filter from your Influx query, and use the `last()` selector. You may have to use the raw query editor to do that - I’m not totally sure. Something like

```auto
SELECT last(voltage) FROM measurement WHERE <your tag filters>

```

should get you what you need.\*

The only issue is with regards to auto-refresh. I don’t think there’s a built-in way to refresh an individual panel, so you’ll indeed need to refresh your whole dashboard in order to get the latest value here.

\*to add: you can also hard-code a time filter in your query. E.g. `WHERE time > now() - 60s` - to ensure that you never show readings that are more than a minute old (in case new readings stop coming in for some reason).

---

<div class="post-metadata">

**Author:** ![jeanmairep](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/jeanmairep/32/17191_2.png) [@jeanmairep](https://community.grafana.com/u/jeanmairep)\
**Post date:** [June 23, 2021, 6:56am UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/9 "2021-06-23T06:56:14Z")

</div>

Thanks a lot @svetb 👍  
That was very very easy.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [June 22, 2022, 9:21pm UTC](https://community.grafana.com/t/stats-not-showing-current-values-when-using-absolute-time-range/49344/10 "2022-06-22T21:21:34Z")

</div>

This topic was automatically closed after 365 days. New replies are no longer allowed.
