=IF(COUNTIFS(A$2:A2,A2,B$2:B2,B2)=1,VLOOKUP(A2&B2,IF({1,0,0},INDEX(Sheet2!$A$4:$A$6&Sheet2!$B$4:$B$6,0),Sheet2!$A$4:$C$6),3,0),0)
Formula is not working for my actual data as my data have many column.
I didn't understand the underlined IF. Please explain.
and customer number is unique so...