Forum Discussion
Help with IF/Search formula
- Oct 11, 2022
reevesgetsaround In the attached I did it both using an array formula that makes the whole table at one time and using a formula that applies to 1 cell at a time and needs to be fill down & right. Here are the formulas I used:
single cell:
=LET(in,D$22,group,$B23, IF(ISNUMBER(in), LET(gtemp,","&TEXTJOIN(,,IFERROR(--MID(group,SEQUENCE(LEN(group)),1),","))&",", IF(ISNUMBER(SEARCH(","&in&",",gtemp)),"Y","")), IF(ISNUMBER(SEARCH(in,group)),"Y","")))whole table:
=LET(colList,$D$12:$Q$12,rowList,$B$13:$B$20, grouplists,SCAN("",rowList,LAMBDA(p,i,","&TEXTJOIN(,,IFERROR(--MID(i,SEQUENCE(LEN(i)),1),","))&",")), MAKEARRAY(ROWS(rowList),COLUMNS(colList),LAMBDA(r,c, LET(in,INDEX(colList,c),IF(ISNUMBER(in), IF(ISNUMBER(SEARCH(","&in&",",INDEX(grouplists,r))),"Y",""), IF(ISNUMBER(SEARCH(in,INDEX(rowList,r))),"Y",""))))))In both cases I convert the text in col B to a list of numbers found inside. In the upper that is line 3 and in the second it is line 2. And then I check if the column is a number and then search for numbers or if not then do a text search.
reevesgetsaround In the attached I did it both using an array formula that makes the whole table at one time and using a formula that applies to 1 cell at a time and needs to be fill down & right. Here are the formulas I used:
single cell:
=LET(in,D$22,group,$B23,
IF(ISNUMBER(in),
LET(gtemp,","&TEXTJOIN(,,IFERROR(--MID(group,SEQUENCE(LEN(group)),1),","))&",",
IF(ISNUMBER(SEARCH(","&in&",",gtemp)),"Y","")),
IF(ISNUMBER(SEARCH(in,group)),"Y","")))whole table:
=LET(colList,$D$12:$Q$12,rowList,$B$13:$B$20,
grouplists,SCAN("",rowList,LAMBDA(p,i,","&TEXTJOIN(,,IFERROR(--MID(i,SEQUENCE(LEN(i)),1),","))&",")),
MAKEARRAY(ROWS(rowList),COLUMNS(colList),LAMBDA(r,c,
LET(in,INDEX(colList,c),IF(ISNUMBER(in),
IF(ISNUMBER(SEARCH(","&in&",",INDEX(grouplists,r))),"Y",""),
IF(ISNUMBER(SEARCH(in,INDEX(rowList,r))),"Y",""))))))In both cases I convert the text in col B to a list of numbers found inside. In the upper that is line 3 and in the second it is line 2. And then I check if the column is a number and then search for numbers or if not then do a text search.
- reevesgetsaroundOct 12, 2022Brass ContributorAnd here's me thinking it would just be a simple tweak!
This works perfectly, you're a genius. Thank You.
Best Regards