Question

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:
enter image description here

Desired output:
enter image description here

Thanks

Was it helpful?

Solution

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.

OTHER TIPS

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

enter image description here

editing a named range

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top