google-sheets

Counting a specific value from the past 7/30 days


I want to count a specific value, in my case how many zeros there are, in the last x amount of days. Also this should be done dynamically, as there's data added every day. This is why I think I have to create the formula dependent on date values.

As of right now I can't provide a sheet with an example, but the example would be pretty simple. Column A has the dates, Column B has the numbers, ranging between 0-1000000. I want to count the 0 over the past 7 days, starting from today.

The last one I've tried using was:

=COUNTIFS(B4:B975;A4:A975;"<="&TODAY();A4:A975;">="&TODAY()-7;"0")

I was playing around with it for a bit as well, but the error always tells me, that either the values inside are a different size or it has to be in pairs. I'm using something similar for AVERAGEIFS, which works flawlessly and so I thought I can just use it for COUNTIFS as well with some minor tweaks, but I guess it's not that simple.

I'm currently using

=COUNTIFS($A$4:$A$975;">="&TODAY()-7;$B$4:$B$975;"0")

but it's a broken formula, since it's also counting all 0 in the future and I've also had no success tweaking this one to work like I've explained.


Solution

  • The syntax seems to be slightly off...

    =COUNTIFS(B4:B975;0; A4:A975;"<="&TODAY(); A4:A975;">="&TODAY()-7)