Hello! I Think it would be easier for you if you use
SUM Functions in Excel Particularly SUMIFS, that formula is a bit too complicated in terms of having an IF function inside another IF Function. This saves a lot of time and thinking.
Hope this helps!