# How do I do this in excel?

**URL:** <https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938>\
**Category:** Factual Questions\
**Created:** [July 12, 2014, 5:26pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938 "2014-07-12T17:26:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![misterW](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@misterW](https://boards.straightdope.com/u/misterW)\
**Post date:** [July 12, 2014, 5:26pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/1 "2014-07-12T17:26:46Z")

</div>

I have a vertical column of dollar amounts of purchases. The next column to the right contains the category that each purchase falls under (for example, “food”, “utilities”, “entertainment”, etc.). So, each purchase amount has a category entry to its immediate right. Is there a way that I can do a sum of all “food” purchases? That is, excel would have to add up all the dollar amounts that are categorized (and immediately to the left of the category label) as “food”.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![eschereal](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/eschereal/32/18939_2.png) [@eschereal](https://boards.straightdope.com/u/eschereal)\
**Post date:** [July 12, 2014, 5:35pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/2 "2014-07-12T17:35:28Z")

</div>

Yes, there is an “if” function, I have used it in the past, but I do not have excel handy just now to tell you the exact syntax. I think it might have been “SUMIF”, search for that.

---

<div class="post-metadata">

**Author:** ![Johnny\_Cashless](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@Johnny\_Cashless](https://boards.straightdope.com/u/Johnny_Cashless)\
**Post date:** [July 12, 2014, 5:39pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/3 "2014-07-12T17:39:25Z")

</div>

Sure, don’t know what version you have but you want the ‘subtotal’ button somewhere on your toolbar/ribbon.

---

<div class="post-metadata">

**Author:** ![misterW](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@misterW](https://boards.straightdope.com/u/misterW)\
**Post date:** [July 12, 2014, 7:01pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/4 "2014-07-12T19:01:24Z")

</div>

I’m using google spreadsheet, which seems to work pretty similar to excel as far as formulas.

---

<div class="post-metadata">

**Author:** ![jonesj2205](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jonesj2205](https://boards.straightdope.com/u/jonesj2205)\
**Post date:** [July 12, 2014, 7:04pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/5 "2014-07-12T19:04:56Z")

</div>

Google spreadsheets I don’t know, but in Excel you’d want a pivot table.  
Subtotal only works if the expenses are sorted by the category. Sumif would work, but pivot table does all the work of creating those sumifs for you.

---

<div class="post-metadata">

**Author:** ![misterW](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@misterW](https://boards.straightdope.com/u/misterW)\
**Post date:** [July 12, 2014, 7:37pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/6 "2014-07-12T19:37:57Z")

</div>

How do you do a sumif with the criteria being that the cell to be summed has a cell to the immediate right that contains a particular word?

---

<div class="post-metadata">

**Author:** ![misterW](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@misterW](https://boards.straightdope.com/u/misterW)\
**Post date:** [July 12, 2014, 7:46pm UTC](https://boards.straightdope.com/t/how-do-i-do-this-in-excel/692938/7 "2014-07-12T19:46:09Z")

</div>

^^Nevermind, I got it. Thanks, the Sumif takes care of it.
