This problem can be easily solved with the SUMIF function or the SUMIFS function.
SUMIF function
TheSUMIF functionis designed to sum cells based on asinglecondition.
For more SUMIF examples,see this page.
For more on concatenation,see this page.
The syntax for SUMIFS is similar, but the order of theargumentsis different.
For more SUMIFS examples,see this page.
Criteria can be applied to dates, numbers, and text.