"Last Value" in legend of most of my panels is wrong

Grafana v10.4.1 (d3ce857c0e), ARMv7 Linux, Raspberry Pi 3b

Trying to show the latest or “last” values in the legend of my dashboard time series panels. Most of the time that value is wrong, and does not line up with what you can see on the graph when you hover over the very end of it. A lot of the time it’s showing a value that must be several hours old.

Here is an example where it shows the CO2 being 100ppm higher than the latest value actually is:

In this case, when accessing the database manually, the graphs are correct, the legend “last” value is wrong.

    "legend": {
      "showLegend": true,
      "displayMode": "table",
      "placement": "bottom",
      "calcs": [
        "last"
      ]
    },

That’s the relevant section of my panel’s JSON. I’m not sure what could be going on here if the graphs are ALWAYS right, but the legend last value is almost always several hours old.

Use Table view and proof that Last value doesn’t match last value of time series (don’t use visual graph as a proof - there can be many issues with times, which may not be visible, e.g. value in the future, …). How datasource query looks like? Why you don’t use Last * (that’s different than Last) value?

1 Like

Thanks for your help! Table view shows the same correct values as graph view, after sorting by time:

I am confirming the table/graph is correct by querying the database in another program (DBeaver), as well as using the display on the CO2 measuring device itself that doesn’t involve the database at all, the value on the display matches the (actual) last value in the database which matches the far right value on the graph and the top of the table, just not the last value in the legend. So as far as I can tell here, the only step that’s getting anything wrong is whatever Grafana is deciding what last means.

I tried last * but it produced the same result, every time, which I would expect:

I would say query should provide time sorted result, try ORDER BY time.

1 Like

EDIT: Whoops, that actually DID work and I just forgot to place it in BOTH my queries lol, thank you!

1 Like