Solved

Excel Sumproduct to Count multiple column criterias once per row and only 2 rows max

Posted on 2013-05-16
5
388 Views
Last Modified: 2013-05-22
Good morning,

I have a table like the following:

A                   B         C         D           E
Equipment   Time   Time   Time  Running
A                    4        5         4         Yes
A                    5        0         0         Yes
A                    6        0         5         Yes
A                    0        5         4         Yes
B                    0        0         0          No

I want to Count the "0" only once per row. I tried using
=SUMPRODUCT((E2:E6="Yes")*(B2:D6=0))
But I get "4" and I only want "3".

I tried
=SUMPRODUCT((E2:E6="Yes")*((B2:B6=0)+(C2:C6=0)+(D2:D6=0)))
And I get "4"

Then, I want to only count 2 out of the 4 Equipment reps if there are multiple "0" in a row.
So I would get "2" and not "3".

Thank you!
0
Comment
Question by:crepe
  • 2
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
NBVC earned 500 total points
ID: 39171717
Try:

=SUMPRODUCT(--(MMULT(--($B$2:$D$6=0),{1;1;1})>0),--($E$2:$E$6="Yes"))
0
 
LVL 23

Expert Comment

by:NBVC
ID: 39171809
For the 2nd part try:

=COUNT(1/FREQUENCY(IF(SUMPRODUCT(--(MMULT(--($B$2:$D$6=0),{1;1;1})>0)),IF($A$2:$A$6<>"",MATCH($A$2:$A$6,$A$2:$A$6,0))),ROW($A$2:$A$6)-ROW($A$2)+1))

confirmed with CTRL+SHIFT+ENTER not just ENTER
(it's an Array formula)
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39172774
NB_VC's suggestion is more easily extensible for multiple columns but for your first question you could amend your suggested formula slightly, i.e.

=SUMPRODUCT((E2:E6="Yes")*((B2:B6=0)+(C2:C6=0)+(D2:D6=0)>0))

The >0 part ensure that you only count each row once at most....

I'm not clear on the second part - how do you get 2?

If you simply never want > 2 then try

=MIN(2,SUMPRODUCT((E2:E6="Yes")*((B2:B6=0)+(C2:C6=0)+(D2:D6=0)>0)))

regards, barry
0
 

Author Comment

by:crepe
ID: 39188608
The 1st part worked beautifully!

The 2nd part doesn't work when I add it to my table. I added the following:
A                   B         C         D           E
Equipment   Time   Time   Time  Running
A                    4        5         4         Yes
A                    5        0         0         Yes
A                    6        0         5         Yes
A                    0        5         4         Yes
B                    0        0         0          No
C                    0        0         2         Yes
C                    0        4         5          Yes
C                    3        0         3          Yes
C                    4        0         5          Yes

I used:
=COUNT(1/FREQUENCY(IF(SUMPRODUCT(--(MMULT(--($B$2:$D$6=0),{1;1;1})>0)),IF($A$2:$A$6<>"",MATCH($A$2:$A$6,$A$2:$A$6,0))),ROW($A$2:$A$6)-ROW($A$2)+1))
with CTRL+SHIFT+ENTER

And I get "3" and I need "4".

I'm going to close this question and start a new question on the 2nd part with modifications. Thank you so much!!
0
 

Author Closing Comment

by:crepe
ID: 39188609
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to read BOM (Byte Order Mark) from csv file. 4 36
ADD New Entries 7 16
Dynamic Filter ? 4 18
Excel - Transposing columns/rows (sort of!) 7 0
A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now