# Sum on condition?

I have set up a form with Google Spreadsheet where I want to collect grocery expenses for different people. How can I sum the expenses for different persons? Each row has a column with the person's name and the amount spent.

Let me give an example for the problem:

Table:

``````A      B
Name Amount
Me    1
You   2
Me    3
Me    4
You   5
``````

I want to SUM column B where column A = "Me" so the result is 8.

You can use the `SUMIF` function to calculate the total sum for each person.

If you enter the following formula in a cell you like, it will give you the total amount spent by "Me":

``````=SUMIF(A2:A6,"=Me",B2:B6)
``````

where `A2:A6` is the `Range`, `"=Me"` is the `Criteria`, and `B2:B6` is the `Sum_Range`.

• Here's how to get a list of available functions – none Feb 23 '11 at 7:50
• For this to work in non-US locales you need to use ";" instead of "," in the statement above. Otherwise you'll get an "#ERROR!". – Emil Stenström Feb 20 '13 at 9:27
• @EmilStenström: True. I have Turkish locale and I always use `;` in Excel formulas. Additionally, if you work with macros in Excel, you always have to use `,` for formulas in your code even if you have non-US locales. – Mehper C. Palavuzlar Feb 20 '13 at 20:10

Since the expenses are for different people I would suggest a pivot table so not only is `Me` summed but so are all other people, and a control total created automatically.

Data > Pivot table... , Add `Name` to Rows and `Amount` to Values as Summarise by SUM: 