vlookupopenoffice-calc

Assign Category Values according to wildcards in assignment table


I am having trouble assigning category Values in a table according to wildcards in another table. There seem to be no function in calc that would help me to solve this problem.

Example:

Data Table (bold values in the category column are inserted by a function)

Sentence Category
This is an BMW model Car
This Phillips is for the kitchen Kitchen applience
This is Synology device NA

Assignment Table

Search Term Category
BMW model Car
Phillips Kitchen applience
* NA

So what I want to achieve is similar to VLOOKUP but the search term (lookup value) and the text must be in the opposite tables.

Is this achievable with only calc functions or do I need a macro for that?

Any help, hints or links to existing solution is much appreciated!

UPDATE: Those tables are on a separate Sheets.


Solution

  • Assume "This is an BMW model" is in cell A2 and "BMW model" is in cell C2. Enter the following formula in cell B2 and drag to fill down.

    =IFERROR(INDIRECT("R"&SUMPRODUCT(COUNTIF(A2:A2;"*"&C$2:C$3&"*")*ROW(D$2:D$3))&"C"&COLUMN(D1);0);"NA")
    

    Result:

    Car
    Kitchen applience
    NA
    

    Breakdown:

    If multiple matches in one sentence are possible, then the formula would need to be modified to handle that.