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

Excel formula for counting the number of rows away from TRUE event in another column

I have an Excel table that looks like this;

enter image description here

The cells in the column Number of rows away from occurrence counts the number of rows that are away from a TRUE event in Occurrence column.

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 to have a formula for the cells in column Number of rows away from occurrence.

I am using Microsoft Excel 2019.

>Solution :

I think this formula in the 2nd column would work:

=IF(A2, 0, SUM(B1, 1))

Copy and paste to all rows in that column. The function looks to see if the current row has a TRUE in the first column. If it does, it sets it to zero. Otherwise, it adds 1 to the value in the previous row of the 2nd column.

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