excelgoogle-sheetssum

Excel or Google Sheets: Sum based on criteria in another column


I have a spreadsheet which contains two columns with two separate values for each row. Each letter indicates a value attached to a variable. The values of the variables change depending on which column they are in.

These are the values if the variable is in the column S1_ST: B=3, C=4, D=4, R=4, W=1, WA=0.

These are the values if the variable is in the column S2_ST: B=2, C=9, D=0, R=6, W=2, WA=0.

I am looking for a formula to return the sum of the value for S1_ST and S2_ST based on the variable entered in those columns.

For Example: https://drive.google.com/file/d/0Byxg512qAqFgX2RyQlh3ellJLTA/view?usp=sharing

So, the value in I2 should be 4.

Hope that makes sense.

Thanks in advance for the ideas.


Solution

  • Use vlookup.

    vlookup

    You can use vlookup or sumifs. See my screenshot with the formula indicated. The number 3 at G1 is calculated from the list of values for the variables.