Hello,
I have a set of data where 15 products represented by 3-digit values were sorted into different groups. I need to populate a cooccurrence matrix, where if two products are in the same group, their intersection in the matrix is assigned a "1"; if not, the intersection can either be left blank or gets a zero. I have come up with a way to do this by typing in each group as a separate column and then using a number of =COUNTIF statements to populate the matrix, but I feel like there must be a more elegant way to do this (maybe with =COUNTIFS and =AND/=OR functions?), but I haven't had any success so far.
I've attached an example spreadsheet with my current solution if anyone would like to take a look. This is the current formula I'm working with from cell B2: =IF(COUNTIF($A$21:$A$36,$A2)+COUNTIF($A$21:$A$36,B$1)=2,1,IF(COUNTIF($B$21:$B$36,$A2)+COUNTIF($B$21:$B$36,B$1)=2,1,IF(COUNTIF($C$21:$C$36,$A2)+COUNTIF($C$21:$C$36,B$1)=2,1,IF(COUNTIF($D$21:$D$36,$A2)+COUNTIF($D$21:$D$36,B$1)=2,1,""))))
My main problem is that there can be up to 2-14 groups (columns) with 1-14 codes in each column, and I feel like repeating the = COUNTIF formula 14 times must be excessive... Any ideas?
Bookmarks