Excel sumif with criteria

旧巷老猫 提交于 2019-12-13 15:37:52

问题


I have a last_name, first_name, salary, and total_salary columns. The sales person appears multiple times throughout the spread sheet. What I would like to do is write a function that will sum up the salary column in the total_salary column only where the sales person appears.

Example output:

Desired output:

Thanks


回答1:


Try this (assuming your data is in columns A:C starting row 1):

=SUMPRODUCT(--(A1=A:A),--(B1=B:B),C:C)

Autofit down the list as required.




回答2:


Use the SumIfs function.

Suppose your data starts in cell A1

You Would have:

A        B       C       D
Brian    Adam    3000    =SUMIFS($C$1:$C$8,$A$1:$A$8,A1,$B$1:$B$8,B1)

And then just drag down column D

Obviously change the $8 part of the function to the correct number of rows for the sheet.




回答3:


Make your fname, lname and sal columns named ranges

use this formula where ever you want.

=SUMIFS(Sal,Fname,"Brian",Lname,"Adam")

or

=SUMIFS(Sal,Fname,"A2",Lname,"B2")

You can replace"Brian" and "Adam" with range references too.

I case you are not familiar: Making a named range

editing a named range



来源:https://stackoverflow.com/questions/15011338/excel-sumif-with-criteria

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!