I can suggest to insert the formula =COUNTIFS($C:$C;$C2;$B:$B;$B2;$A:$A;$A2) in the column next to Custom String 2 to get the Role number for the row.
Then you can insert the formula =IF(A2=A1;IF(B2=B1;IF(C2=C1;1;0);0);0) in the column next to the R...