COUNTIFS and SUMPRODUCT yield different answers from same data source

WildWill

Board Regular
Joined
Sep 10, 2009
Messages
92
Hi

I have a dataset that contains a wide range of HR-related information (could not post it here using Excel Jeanie due to size). From this same data set, two different formulae are giving two different answers, and this is driving me nuts. I have looked at all the possible causes in terms of data integrity etc. and I just cant understand why these would yield different answers. Please help.

The items being measured in both cases are totals of Rig-Based Employees (a) and Totals of Non-Rig Employees (b). If I use the SUMPRODUCT formulae below for respectively (a) and (b) , I get (a) = 165 and (b) = 25:

formula for a: =SUMPRODUCT((Source!$D$4:$D$203=SUMPRODUCT!A2)*(Source!$G$4:$G$203<>"Leaver")*(Source!$G$4:$G$203<>"Transfer Out"))
formula for b: =SUMPRODUCT((Source!$D$4:$D$203=SUMPRODUCT!A3)*(Source!$G$4:$G$203<>"Leaver")*(Source!$G$4:$G$203<>"Transfer Out"))

Now, with the same dataset, a different approach using a COUNTIFS formula (below) yields (a) = 166 and (b) = 24:

(Again, this is complicated to show without being able to attach the worksheet, but the below formula is repeated in a table for all the different permutations of data)

=SUM(COUNTIFS(Source!$C$4:$C$203,COUNTIFS!C4,Source!$B$4:$B$203,"Non-Local",Source!$F$4:$F$203,{"Expat","TCN"},Source!$G$4:$G$203,{"Starter";"Transfer In";""}))
Is there any other way that I can share the sheets here? sure that will simplify what I am trying to show.

Will
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
hello!
if you could not post it here using Excel Jeanie why don't you use Mr.excel.HTMLMaker
Please provide details of data layout with just few rows and colunms with the expected outcome so we can understand better?
I suggest you to post a nice HTML screen-shot with Mr.Excel HTML Maker (not a picture), if you don’t know how to istall and how to use it watch the video linked in my signature!!
help us to help you
Thank you in advance!
 
Upvote 0
Now, with the same dataset
But... They're NOT the same dataset...

The sumproduct formulas are referring to
Source!$D$4:$D$203 and Source!$G$4:$G$203

The countifs is referring to
Source!$C$4:$C$203 and Source!$B$4:$B$203 and Source!$G$4:$G$203


They're not even doing the same thing,
sumproduct is counting rows where D = A2 AND G does not = Leaver or Transfer Out
countifs is counting rows where C = C4, AND B = Non Local AND F = Expat or TCN AND G = Starter Transfer in or ""


I don't understand your surprise that the 2 formulas give different results.
 
Upvote 0
Hi Jonmo1

Yes, I do realize that - but the two different sets of formulae approach the data in completely different manners, and it is the fact that I cant easily show the tabe that is being used in the COUNTIFS approach, that is (hopefully) the missing part. I will upload using Mr Excel Maker.
 
Upvote 0
This formula
=SUM(COUNTIFS(Source!$C$4:$C$203,COUNTIFS!C4,Source!$B$4:$B$203,"Non-Local",Source!$F$4:$F$203,{"Expat","TCN"},Source!$G$4:$G$203,{"Starter";"Transfer In";""}))

Is NOT an equivelant of this formula
=SUMPRODUCT((Source!$D$4:$D$203=SUMPRODUCT!A2)*(Source!$G$4:$G$203<>"Leaver")*(Source!$G$4:$G$203<>"Transfer Out"))


This would be
=SUM(COUNTIFS(Source!$D$4:$D$203,SUMPRODUCT!A2,Source!$G$4:$G$203,<>"Leaver",Source!$G$4:$G$203,"<>Transfer Out"))
 
Upvote 0
Jonmo1

The SUMPRODUCT formulae search directly on the source data table, while the COUNTIFS formula is applied to a table layout where the source data is first calculated segments according to where the employee works, and what type of employee we are dealing with, this is why the formulae don't appear the same. But I am aware of what you are saying, it's just difficult for me to express without showing you the actual spread sheet. As indicated before, I have placed in in Dropbox with this link, can you use that please? https://www.dropbox.com/sh/rqmlwqgnmnd14gc/AADbXJrq9wrsH5dLdWg3g24La?dl=0
 
Upvote 0
Hello!
Your formula works fine
I tried with define name so I don't have to jump sheet by sheet




Book1
AB
1
2Rig165
3Non-Rig25
4
5
6
7
8
9
10B=payrooll
11C= personal sub area
12D= allocation
13F=Employment Class
14G=Movement Type
SUMPRODUCT
Cell Formulas
RangeFormula
B2=SUMPRODUCT((Allocation=A2)*(Movement_Type<>"Leaver")*(Movement_Type<>"Transfer Out"))
Named Ranges
NameRefers ToCells
Allocation=Source!$D$4:$D$203
Movement_Type=Source!$G$4:$G$203







Book1
BCDEFG
3PayrollPersonnel Sub AreaAllocationContract TypeEmployment ClassMovement Type
4LocalFinance & AdminNon-RigLocal
5LocalGlobal Sup MgtNon-RigLocal
6LocalGlobal Sup MgtNon-RigLocal
7LocalGlobal Sup MgtNon-RigLocal
8LocalMaintenanceNon-RigLocal
9LocalHRNon-RigLocalLeaver
10LocalHRNon-RigLocalLeaver
11LocalHRNon-RigLocalLeaver
12LocalHRNon-RigLocal
13LocalHRNon-RigLocal
14LocalT-221RigLocal
15LocalT-221RigLocal
16LocalT-221RigLocal
17LocalT-221RigLocal
18LocalT-221RigTCN
19LocalT-221RigLocal
20LocalT-221RigLocal
21LocalT-221RigLocal
22LocalT-221RigLocal
23LocalT-221RigLocal
24LocalT-221RigLocal
25LocalT-221RigLocal
26LocalT-221RigTCN
27LocalT-221RigLocal
28LocalT-221RigLocal
29LocalT-221RigLocal
30LocalT-221RigLocal
31LocalT-221RigLocalLeaver
32LocalT-221RigLocal
33LocalT-221RigLocal
34LocalT-221RigLocal
35LocalT-221RigLocal
36LocalT-221RigLocal
37LocalT-221RigLocal
38LocalT-221RigLocal
39LocalT-221RigLocal
40LocalT-221RigLocal
41LocalT-221RigLocal
42LocalT-221RigLocal
43LocalT-221RigLocal
44LocalT-221RigLocal
45LocalT-221RigLocal
46LocalT-221RigLocal
47LocalT-221RigLocal
48LocalT-221RigLocal
49LocalT-221RigLocal
50LocalT-221RigLocal
51LocalT-221RigLocal
52LocalT-221RigLocal
53LocalT-221RigLocal
54LocalT-221RigLocal
55LocalT-221RigLocal
56LocalT-221RigLocal
57LocalT-221RigLocal
58LocalT-221RigLocal
59LocalT-221RigLocal
60LocalT-221RigLocal
61LocalT-221RigLocal
62LocalT-221RigLocal
63LocalT-221RigLocal
64LocalT-221RigLocal
65LocalT-221RigLocal
66LocalT-221RigLocal
67LocalT-221RigLocal
68LocalT-221RigLocal
69LocalT-221RigLocal
70LocalT-221RigLocal
71LocalT-221RigLocal
72LocalT-221RigLocal
73LocalT-221RigLocal
74LocalT-221RigLocal
75LocalT-221RigLocal
76LocalT-221RigLocal
77LocalT-221RigLocal
78LocalT-63RigLocal
79LocalT-63RigLocal
80LocalT-63RigLocal
81LocalT-63RigLocal
82LocalT-63RigLocal
83LocalT-63RigLocal
84LocalT-63RigLocal
85LocalT-63RigLocal
86LocalT-63RigLocal
87LocalT-63RigLocal
88LocalT-63RigLocalLeaver
89LocalT-63RigLocal
90LocalT-63RigLocal
91LocalT-63RigLocal
92LocalT-63RigLocal
93LocalT-63RigLocal
94LocalT-63RigLocal
95LocalT-63RigLocal
96LocalT-63RigLocal
Source
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,455
Members
449,228
Latest member
moaz_cma

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top