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

Viewed 59

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.

I would like to have a formula for the cells in column Number of rows away from occurrence.

I am using Microsoft Excel 2019.

1 Answers

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.

Related