简体   繁体   中英

array formula to auto increment if conditions

Need array formula to auto increment column A when date is set and amount is not equal to 0

sheet link

在此处输入图像描述

Use scan() , like this:

=arrayformula( 
  if( 
    len(B2:B) * (to_text(C2:C) <> "0"); 
    scan( 
      ""; isdate_strict(B2:B) * (to_text(C2:C) <> "0"); 
      lambda( 
        result; increment; 
        result + increment
      )
    ); 
    iferror(1/0) 
  ) 
)

Here's one way you could do that:

=ArrayFormula(IF(B2:B*(C2:C&""<>"0");SCAN(;ROW(B2:C)-1;LAMBDA(a;c;a+IF(INDEX(B2:B;c)*INDEX(C2:C&""<>"0";c);1)));))

another approach:

=LAMBDA(y,MAP(INDEX(y,,1),INDEX(y,,2),LAMBDA(r,c,IF(r=0,,c))))(LAMBDA(z,{z,SCAN(,z,LAMBDA(ac,cv,ac+cv))})(INDEX(ISDATE_STRICT(B2:B)*(C2:C&""<>"0"))))

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM