Thank you very much to both of you.

Both formulas work on the data I provided but there's issue with the =SUMPRODUCT(($A$2:$A$15=D2)/COUNTIF($B$2:$B$15,$B$2:$B$15&"")) if you change the value in B4 to match B6. Why is that?