How do I obtain a result when I want to sum the values in a column only if conditions are met in two other columns?