Set grouped values to specific value

Dear community,

I am plotting measurement values stored in an influxdb with Grafana as bar plot. The values are aggregated on a daily basis ( aggregateWindow(every: 1d, fn: sum). Under certain conditions the measurement drops out and the daily sum does not become meaningful. I want to set the value of those these days to a predefined value.

My idea to implement this is so far like this:
Count the entries of my measurement per day and store them in a separate value:

 |> filter(fn: (r) => r._measurement == "my_measurement")
 |> aggregateWindow(every: 1d, fn: count, createEmpty: false)
 |> map(fn: (r) => ({ entries:r._value, Time:r._time,}))

If there are less than 1000 entries per day, the data of that day is invalid. Currently I am struggling on the correct way to implement this. I am trying this with a math-expression. “$entries > 1000” gives a 0/1 plot. But I could not figure out how to implement something like “if ($entries > 1000) then <put out $my_measurement> else $my_measurement = -1”.

Any hints on implementing this would be appreciated!

Thanks!