Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to count specific values between other values

I’m having a hard time figuring this one out.

I have a short list of numbers in column C (C4 to C19).
Those numbers can range from 0 to anything. Never empty.

In column D is a date, in column E is an offset, but this is not relevant to the problem.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I would like in column F, the count of the value zero, before that line, until we find a non-zero value above that.

So, let’s say F18. I want to know the count of zeroes in C before C18. The answer is 3.
For F17, the answer is 2 (C16 and C15).
And so on.

Image

I did try to figure it out with some COUNTIFS and INDEX…. but I’m lost.

>Solution :

This one does it the other way around (top to bottom):

=IFERROR(SCAN(0,C4:C19,LAMBDA(a,v,IF(v=0,a+1,0))),"")

I hope I’m not breaking any rules, but here is it in French:

=SIERREUR(SCAN(0;C4:C19;LAMBDA(a;v;SI(v=0;a+1;0)));"")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading