Excel Function SumIfs

I was wondering if it is possible to sum data(I know now you have to use Sum if) if it meets a certain criteria but I was wondering if you had two columns, A and B, where if say B1 is zero when you sumif from a different sheet leave it as 0, but if not, then Add up with the same formula the sumif value you would’ve got + A1 value.

Is it possible to do it in one formula and how, so basically while doing the sumif, if it’s zero leave it as zero, if not, then add up the value of the previous coloumn to the one calculated all in one cell