How to ignore zero values with: aggregatewindow fn: last

Hi folks,

not sure if there is any possible way to address my issue:

  • What Grafana version and what operating system are you using?
    10.0.3 running in Docker

  • What are you trying to achieve?
    I’d like to use the aggregatewindow function to display data grouped per day, showing the last value provided for that day, BUT omitting zero values

  • How are you trying to achieve it?
    |> aggregateWindow(every: 1d, fn: last, createEmpty: true)

  • What happened?
    See screenshot, the value for 16th Aug. is 0
    Actually the data is correct, as the last value for this day is in deed zero.

  • What did you expect to happen?
    Zero values should be omitted. In this case the last non-zero value should be used.

  • Can you copy/paste the configuration(s) that you are having problems with?
    see above

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

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

Welcome @stefan300381 to the Grafana forum.

Have you tried adding a filter function just before the aggregateWindow function, like this?

|> filter(fn: (r) => r._value != 0)

Remember Flux is a pipe forward language where the 0 values will be excluded BEFORE they are aggregated. You could also try putting the above filter AFTER the aggregateWindow function to compare your results.

awesome, it works, thanks a lot