Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help on how to create a formula

Status
Not open for further replies.

Kenja824

Automotive
Nov 5, 2014
950
Column A has names of people
Column B has months
Column C has week days

I would like to look for certain criteria in all three columns and sum up the totals from column E.

For instance
Ken may be in column A 13 times.
March is in Column B 34 times
Monday shows up in column C 57 times

All three of these are on the same row 6 times. I need a formula to give the sum of all 6 instances where all three fall in the same row.

How would you write that formula?
 
Replies continue below

Recommended for you

Ken,

Convert your table to Structured Table, assuming every column in your table has unique headers. So list the headers for columns a,b,c&e.

The SUMPRODUCT() function will do nicely, as I can demonstrate with a table with Name, Month, Amt

=SUMPRODUCT((Table1[Name]=A2)*(Table1[Month]=B2)*(Table1[Amt]))

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
..and the reason I ALWAYS use SUMPRODUCT, rather than SUMIFS or COUNTIFS is 1) its more intuitive and 2) becomes much more self documenting than using anonymous range references.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Ok I got it....

I was using the Sumif but for some reason it wasnt reading right. It turned out it was reading a cell it didnt like in one of the columns. I was using full columns "A:A" and I had to give it an actual range "A5:A500". Once I did that, it worked.

Hey Skip [bigsmile]

I will look into that. For some reason because I am not real comfortable using tables, I always tend to shy away from them. lol
I need to just start using them to get used to them. Everyone keeps telling me I should. lol

 
So what's more understandable: A5:A500 or Table1[Names]?

It would even be better if the table name was something meaningful, too.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Eventually Excel will work just like Jazz did.
 
What was Jazz & how did it work?

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
An example...

[tt]=SUMPRODUCT((Table1[Name]=H$1)*(Table1[Month]=$F2)*(Table1[DOW]=$G2)*(Table1[Amt]))[/tt]

And if you were counting occurrences rather than summing and rather than using COUNTIFS()

[tt]=SUMPRODUCT(--(Table1[Name]=H$1)*(Table1[Month]=$F2)*(Table1[DOW]=$G2))[/tt]
NOTICE the similarities and the intuitive nature of each expression within parentheses as compared to having to put operators in QUOTES when using SUMIFS() and COUNTIFS()

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
 https://files.engineering.com/getfile.aspx?folder=2ba75a46-5088-4879-a264-491bed138dc7&file=tt-KenSumproduct.xlsx
I think it's important to look at how you're going to use the formula, too. (Maybe it's obvious to everyone else, and I'm just missing it.) How do you know what you're looking for? If you have 20 different names, 12 months, and 7 days, you'll need to define the combination you want to count. This is how I would do it:

1) Create a list of all possible names, and name it Names (highlight the list, go to the upper right corner of the sheet to the "name box" and type in the name).
2) Repeat #1 for months and one for days.
3) Pick three cells, and in each one of them use Data Validation to create drop-down lists. Define the source as the name of your list. Now, you have drop down lists to define your search combination.
4) In cell D1, enter the formula =COUNTIF(A1,<Name Drop Down Cell>)+COUNIF(B1,<Month>)+COUNTIF(C1,<Day>)
5) In cell E1, enter the formula =COUNTIF(D1,3)
6) Wherever you want your total, enter the formula =SUM(E:E)

It's not as elegant as Skip's solution, but it's pretty straightforward and easy to do without relying on some of Excel's more "advanced" features.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor