I am trying to get the previous year values sum as a single value. The expected answer is 8265 (from influxdb) but the answer being fetched in grafana is 7874. Please refer my query below:
keep returns only the _value column, it drops everything else, so the drop after that is useless.
from the query I am assuming sensor is a tag, and your results are grouped in 2 different “sensors”. when you dropped all other columns with keep, instead of having 2 tables with 1 row (each sensor with its total), you now have 1 single table with 2 _value rows.
and in stat panel you are selecting to calculate last value, try total to get the sum of those 2 rows instead of the last one.