mercredi 22 mai 2019

Using an IF Statement to do multiple searches in an array formula

I'm working on trying to get some formula working that'll vastly improve my QOL at work. I want the formula to run 2 searches for keywords that will be present in my "Title" column and my "SKU" column then return results based on a key that I have located in a second tab.

https://gyazo.com/e6a3914ea9a96f8dcdce47d9ec704b37

The above screenshot is my key. If products contain any of the keywords in the title column then the corresponding category is automatically assigned.

In the example screenshot below I have the formula working to do 1 search. It's searching the "Title" column (B) against the Keywords column in the Key and if the word exists within the title it gives a result back based on the row that the result was on.

https://gyazo.com/63f98251dac757378ceadbfe3e4167a6

What I want to achieve is to do multiple searches within the same column. I want to be able to firstly do the search by "Title", if no results are returned then I want it to search via the "SKU" column against the Keywords and Categories in the Key (Columns C & D)

In the below screenshot I've tried wrapping it in an IF statement IF(TITLESEARCH=""),(SKUSEARCH),(TITLESEARCH)

https://gyazo.com/ed2786ca733660fa49b9c4716a5efa9a

The results I'm getting back seem to be working for the first part of the IF statement. It's giving me back results that are correct for the first part of the IF statement, but the second part doesn't seem to be working correctly and I can't figure out why. Where it should be assigning the category "Accessories" it's just giving me "FALSE" instead.

Here's a link to the spreadsheet if anyone would like to take a look. I've been wracking my brain on this for a few days now and I feel like I've come a long way.

https://docs.google.com/spreadsheets/d/1548QMP5qeAIFrbraGD_lkJkQWzKF4Td6FR1KkcOHHJM/edit?usp=sharing

I'm quite new to googlesheets and excel formula (especially on this level) so please be gentle. It feels like the mistake I'm making might be glaringly obvious.

https://exceljet.net/formula/categorize-text-with-keywords

This is what my formula is based on.

=IF(ARRAYFORMULA(INDEX('Array Key'!B:B,MATCH(TRUE,ISNUMBER(SEARCH('Array Key'!A:A,B234)),0)))="",(ARRAYFORMULA(INDEX('Array Key'!D:D,MATCH(TRUE,ISNUMBER(SEARCH('Array Key'!C:C,A234)),0),(ARRAYFORMULA(INDEX('Array Key'!B:B,MATCH(TRUE,ISNUMBER(SEARCH('Array Key'!A:A,B234)),0))))))))

Aucun commentaire:

Enregistrer un commentaire