简体   繁体   中英

In Excel can I write a formula that will calculate the sum of a column based on the contents of another column?

In Excel can I write a formula that will calculate the sum of a column based on the contents of another column? In the example below, the formula would output '12' if I wanted to see all sales with a category of 'Email'.

This was my idea, but it doesn't work.

=SUMIF(table1[Sales],AND(table1[Category]="Email",table1[Subcategory]="Content"))

A       | B         | C
-----------------------------------
Sales   | Category  | Subcategory
===================================
10      | Email     | Content
-----------------------------------
5       | Web       | Non-Content
-----------------------------------
2       | Email     | Content

You want SUMIFS() with an S :

=SUMIFS(table1[Sales],table1[Category],"Email",table1[Subcategory],"Content")

Criteria are always done in twos:

  • A range the same size as the one being summed
  • The criteria as a string( = being the default)

You can add others or only have one:

=SUMIFS(table1[Sales],table1[Category],"Email")

Which does the same as SUMIF() with slightly different order of criteria.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM