SOLVED

Counting consecutive cells equal to 0 at the end of the range

Brass Contributor

Hell everybody,

 

I am looking for a formula to count the consecutives values of 0 at the end of a line.

Let me show you an example with the expected result. Let's say the only two values in this table are 0 or 1:

durendal_0-1668589703902.png

 

I havn't been able to find a formula, especially with the fact that I don't want the maximum consecutive values of zero in the line, but only the consecutive values from the end of the line.

 

Thank you all

3 Replies
best response confirmed by durendal (Brass Contributor)
Solution

@durendal 

=BYROW(C3:N5,LAMBDA(row,12-LARGE(IF(row>0,COLUMN(C3:N3)-2),1)))

With Office365 or Excel 2021 or Excel online you can try this formula.

zero.JPG

=12-LARGE(IF(C5:N5>0,COLUMN(C3:N3)-2),1)

With older versions you Excel you can try this formula. Enter the formula with ctrl+shift+enter if you don't work with Office365 or 2021.

 

Thank you very much @OliverScheurich that's perfect!

@durendal 

This is just a variation that uses XMATCH and names the Lambda function

WorksheetFormula
= BYROW(array, FinalZerosλ);

FinalZerosλ 
= LAMBDA(row,
    COLUMNS(row) - XMATCH(TRUE, row>0, ,-1)
  );

image.png

 

1 best response

Accepted Solutions
best response confirmed by durendal (Brass Contributor)
Solution

@durendal 

=BYROW(C3:N5,LAMBDA(row,12-LARGE(IF(row>0,COLUMN(C3:N3)-2),1)))

With Office365 or Excel 2021 or Excel online you can try this formula.

zero.JPG

=12-LARGE(IF(C5:N5>0,COLUMN(C3:N3)-2),1)

With older versions you Excel you can try this formula. Enter the formula with ctrl+shift+enter if you don't work with Office365 or 2021.

 

View solution in original post