Search code examples
google-sheetsmatchgoogle-sheets-formulaarray-formulasgs-vlookup

Comparing attributes from 2 sets


I have 2 sets of data, let's say, Workers and Platform. Both have attributes, say, Drilling, Grinding, Hammering.

I need a way to compare, in Excel, the attributes for each element within both sets. For example, if Platform A requires Hammering and Drilling, and Worker A has Drilling, Grinding and Hammering, he'd be accepted for platform A. Worker B only has Drilling, so he'd be rejected at platform B.

The following spreadsheet illustrates this clearly:

https://docs.google.com/spreadsheets/d/1qvkZbDNIWe9gmFjGNr4dhtvqagJZOkS89YD4fzqjvQQ/edit?usp=sharing

In the sheet, "Canta Baila Pinta" are the attributes. The solution I've come up so far is: Generate a string for each Worker and Platform, which equals to its attributes

How do I compare both strings as if to ask, "Does string B contain any element not present in B?"

Furthermore, this code is not dynamic... how would you go about making it so that any newly added attribute got processed automatically, without user intervention?


Solution

  • This isn't dynamic, but here's another approach that may be of interest:

    =ArrayFormula(mmult(if(Trabajadores!E2:G6="Sí",1,0),if(Plataformas!B2:F4="Sí",1,0))=
    mmult(transpose(row(Plataformas!B2:F4))^0,if(Plataformas!B2:F4="Sí",1,0)))
    

    enter image description here

    The idea is that you multiply the Trabajadores and Plataformas matrices (converting Sí into 1, anything else to zero) to count the number of correspondences in skills for each worker/platform combination. Then you calculate the column totals of requirements in the plataformas matrix by doing another mmult, and finally compare the results to see which workers have the required number of skills for each platform.