Home > Software engineering >  Array formula to compare two multi-word text strings
Array formula to compare two multi-word text strings

Time:11-24

I want to compare text strings in two columns (J and O) on one sheet to a list of items ($N$5:$N$23) on another sheet. I want the comparison to be able to search if there are ANY word matches between J and the list OR O and the list (some of the strings are multi-word). This formula works for me when I use it in each cell in the column where I want the results (starting with row 3):

=IF(SUMPRODUCT(ISNUMBER(SEARCH(TRANSPOSE(Lists!$N$5:$N$23),J3&O3)))>0,"YES","NO")

HOWEVER, rather than that formula being in each cell, I now want to fill the formula down the column using an ARRAYFORMULA. It seems you can't use SUMPRODUCT with an array in Google Sheets, so I'm now splitting up the text in column J and O with a space delimiter and comparing that to the values in list $N$5:$N$23 using ARRAYFORMULAs -- arrays within an array. I'm adding the two results to see if their sum is greater than 0, in which case I return "YES."

ARRAYFORMULA(IF(
   SUM(ARRAYFORMULA(IFERROR({SEARCH(SPLIT(J3:J," "),Lists!$N$5:$N$23)},0))) 
   SUM(ARRAYFORMULA(IFERROR({SEARCH(SPLIT(O3:O," "),Lists!$N$5:$N$23)},0)))
   >0,"YES","NO"))

This array formula doesn't want to fill down (starting at row 3). It gives me a value in row 3, but no further.

Questions:

  • Why isn't this array formula filling down?
  • Is there a better/more efficient way to do this comparison? (Maybe with Query?)

Here is a copy of the Google Sheet. I've tried to put the new ARRAY formula into cell Database!P3. Column Q of the Database sheet has the first formula which seems to be working fine. enter image description here

  • Related