Search code examples
google-sheets

If a cell contains a value from a list, return the value of the cell adjacent to the list


I have a list of racing codes, and those codes can be sorted into 3 Groups (Flats, Harness, Jumps). If the Racing Code contains either "Pace or "Trots" then it is in group "Harness". If it contains either "Chs" or "Hrd" then it is in group "Jumps". If it contains niether of those four words, then it is in group "Flats". I want to create a formula that searches a list containing (Pace, Trots, Chs, Hrd) and then return the value of either Jumps or Harness, and if it doesn't match returns Flats. I've linked a Google Sheet. https://docs.google.com/spreadsheets/d/18m9rZRpBvan36-4LR2KqWdLtztNZOlljAWICFtMqqAE/edit?usp=sharing

I have googles and watch videos using IF, OR and SEARCH functions but can't adapt either to my situation and make it work.


Solution

  • Can you test:

    =map(A2:A,lambda(Σ,if(Σ="",,iferror(+tocol(map(D2:D,E2:E,lambda(d,e,if(d="",,if(regexmatch(Σ,"(?i)\b("&d&")\b"),e,)))),1),"Flats"))))
    

    enter image description here