简体   繁体   中英

Excel sumif with criteria

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

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.

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.

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

在此输入图像描述

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