Solved

Help needed in Excel with SUMPRODUCT/COUNTIFS

Posted on 2013-06-12
4
720 Views
Last Modified: 2013-06-22
I have a question on the ability (or syntax) to combine SUMPRODUCT with COUNTIFS.
 
This formula returns the correct value
 
=SUMPRODUCT(COUNTIFS('Selected VDOTs'!$D$2:$D$541,M$1,'Selected VDOTs'!$C$2:$C$541,"9=High",'Selected VDOTs'!$G$2:$G$541,"Clean-Up",'Selected VDOTs'!$J$2:$J$541,{"Changes Required","Validated"}))
 
…well sort of.  The actual count is 16.  But, it’s returning 15.75. Does anyone know why?  (I changed the format of the number to 0 digits to force it to round up.  But, that’s causing a problem with Excel calculated 15.25.)
 
However, when I add the unique flag (1), the formula does not work at all.  (Is it because I’m trying to use it with COUNTIFS?)
 
=SUMPRODUCT(1/COUNTIFS('Selected VDOTs'!$D$2:$D$541,M$1,'Selected VDOTs'!$C$2:$C$541,"9=High",'Selected VDOTs'!$G$2:$G$541,"Clean-Up",'Selected VDOTs'!$J$2:$J$541,{"Changes Required","Validated"}))
 
Also,
 
How can I use an “Or” condition similar to the above with one of my criteria statements in COUNTIFS?  When I only have 1 value as my criteria for any given column, the formula works great:
=SUMPRODUCT(1/COUNTIF('Selected VDOTs'!$E$2:$E$541,'Selected VDOTs'!$E$2:$E$541)*('Selected VDOTs'!$D$2:$D$541=S$1)*('Selected VDOTs'!$C$2:$C$541="9=High")*('Selected VDOTs'!$G$2:$G$541="Clean-Up"))

Please see the attached Word doc with snippets of the data.
excel-question.docx
0
Comment
Question by:Feisty472
  • 2
4 Comments
 
LVL 33

Expert Comment

by:Norie
Comment Utility
Could you attach an Excel document with the data?

Otherwise we'll be kind of guessing where it should go if we try to replicate your setup.
0
 
LVL 50

Expert Comment

by:barry houdini
Comment Utility
You say that this formula returns 15.75

=SUMPRODUCT(COUNTIFS('Selected VDOTs'!$D$2:$D$541,M$1,'Selected VDOTs'!$C$2:$C$541,"9=High",'Selected VDOTs'!$G$2:$G$541,"Clean-Up",'Selected VDOTs'!$J$2:$J$541,{"Changes Required","Validated"}))

I'd be very surprised, I think one of the other formulas might but in the above COUNTIFS can only return whole numbers and SUMPRODUCT is simply summing those.

Where you have divided 1 by COUNTIFS that might give you a non-integer result.....

I'm not really sure what you are trying to do with this formula, can you explain in words what you are trying to do, why the reference to column E, is that where you want the unique count?

=ROUNDUP(SUMPRODUCT(1/COUNTIF('Selected VDOTs'!$E$2:$E$543,'Selected VDOTs'!$E$2:$E$543)*('Selected VDOTs'!$D$2:$D$543=B$1)*('Selected VDOTs'!$C$2:$C$543="9=High")),0)

As it stands I don't think that formula will work to do what you want, you can't simply combine a 1/COUNTIFS with other criteria to get a unique count

regards, barry
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
Comment Utility
generically to return a unique count of items in col1 where col2, col3 and col4 meet conditions you can use a formula like this

=SUM(IF(FREQUENCY(IF((Col2=Cond2)*(Col3=Cond3)*(Col4=Cond4),IF(Col1<>"",MATCH(Col1,Col1,0))),ROW(Col1)-MIN(ROW(Col1))+1),1))

confirmed with CTRL+SHIFT+ENTER

you can add or subtract conditions from this part as required

(Col2=Cond2)*(Col3=Cond3)*(Col4=Cond4)

....and if any of the conditions are for multiple matches you can use ISNUMBER(MATCH, so if col3 can be "x", "y" or "z" change to

(Col2=Cond2)*(ISNUMBER(MATCH(Col3,{"x","y","z"},0)))*(Col4=Cond4)


so with your data if the intention is to get a count of different col E values with the following criteria in other columns:

where col D = B1
where col C = "9=High"

then the formula can be as follows

=SUM(IF(FREQUENCY(IF(('Selected VDOTs'!$D$2:$D$543=B$1)*('Selected VDOTs'!$C$2:$C$543="9=High"),IF('Selected VDOTs'!$E$2:$E$543<>"",MATCH('Selected VDOTs'!$E$2:$E$543,'Selected VDOTs'!$E$2:$E$543,0))),ROW('Selected VDOTs'!$E$2:$E$543)-ROW('Selected VDOTs'!$E$2)+1),1))

confirmed with CTRL+SHIFT+ENTER

regards, barry
0
 

Author Closing Comment

by:Feisty472
Comment Utility
Thanks Barry!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

9 Experts available now in Live!

Get 1:1 Help Now