Hi and welcome to the forum

Hard to offer specific suggestions without seeing samples of what you are working with, but maybe take a look at using sumif() or countif() or something along those lines?