from your sample file can you try this one
for master category 1

=SUMPRODUCT(SUMIF($C$1:$C$10,"*"&$B$15:$B$17&"*",$A$1:$A$10))

for master category 2

=SUMPRODUCT(SUMIF($C$1:$C$10,"*"&$B$18:$B$20&"*",$A$1:$A$10))

let me know if this will work for you. thanks.