Home > Software engineering >  Best approach for formula of matching values in sheet 2
Best approach for formula of matching values in sheet 2

Time:08-25

I need to populate column A in sheet two based on multiple columns in sheet one.

For example, here are two of multiple conditions:

  • If columns A,B,C,D (of sheet 2) are all 5/6 then populate corresponding row in sheet one with "mid".

  • If columns A,B,C,D (of sheet 2) contain at least one 3 and L,M,O contain all 0s, populate "low".

I believe using SWITCH would make the most sense, unless someone can reccommend a simpler approach?

My main issue is with the syntax of writing this, I am getting a formula parse error:

=SWITCH(Sheet 1!G2:G&K2:K,ISBETWEEN(5,6),"mid")

Sheet 1 
A B C D E F G H I J K L M N O 
2 2 3 2               0 0 0 0
5 5 6 6

In row one of my example sheet 2 would get "mid" and row 2 would get "low"

CodePudding user response:

try:

=ARRAYFORMULA(
 IF( 4=LEN(REGEXREPLACE(FLATTEN(QUERY(TRANSPOSE(A1:D5),,9^9)), "[^5-6] ", )), "mid", 
 IF((4=LEN(REGEXREPLACE(FLATTEN(QUERY(TRANSPOSE(L1:O5),,9^9)), "[^0] ", )))*(REGEXMATCH(FLATTEN(QUERY(TRANSPOSE(A1:D5),,9^9)), "3")), "low", )))

enter image description here

  • Related