Search code examples
if-statementgoogle-sheetsvlookuparray-formulascountif

Google sheet array formula running count


I would like to create an array formula for a running count/index based on certain criteria. I can create the count/index with standard formulas but would like to be able to insert rows without adjusting the formulas everytime

Herewith a link to a sheet that shows the desired result in green for all items that match C in the index column

Array formula for indexing sheet


Solution

  • try:

    =ARRAYFORMULA(IF(C2:C="",, IF("C"=VLOOKUP(ROW(A2:A), 
     IF(A2:A<>"", {ROW(A2:A), A2:A}), 2, 1), 
     COUNTIFS(A2:A, "C", ROW(A2:A), "<="&ROW(A2:A)), 0)))
    

    enter image description here