Sumproduct not correct

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Book4
ABCDEFGHIJKLMNOPQR
1ID no.CourseUnit1Unit2Unit3Unit4Unit5Unit6Unit7Unit8Countif CreditsSumproduct CreditsCredits given
2ID 1DiplomaABC2020 56-PABC2040 28-NABC1110 30-NABC1090 61-CABC2690 61-CABC2090 28-NABC1110 50-PABC1040 61-C20DiplomaABC2*PABC2*CABC2*D
3ID 2CertificateABC2020 36-NABC2090 81-HDABC2040 66-CABC2040 66-CABC2040 66-CABC2070 66-CABC2140 66-CABC2100 66-CCertificateABC2*PABC2*CABC2*D ABC1040
4ID 3DegreeABC2110 50-PABC1110 50-PABC1110 50-PABC1040 61-CDegreeABC2*CABC2*D
5ID 4DiplomaABC2110 50-PABC1110 50-PABC1110 50-PABC1040 61-C
Sheet1
Cell Formulas
RangeFormula
K2K2=SUM(COUNTIF(C2:J2,$O$2:$Q$2))
L2L2=SUMPRODUCT(1*(C2:J2=$N$6:$N$8))
Press CTRL+SHIFT+ENTER to enter array formulas.

I can get this to work if I stick with Countif but I'd like to know what I have to tweak to get the Sumproduct to work. Basically in this example I am trying to work out credits based on student results. There is an added complication here in that the number of credits will vary according to the level of qualification so in this system a certificate would receive less credits than a diploma. I think I can work out a lookup/choose option for that part. It's the Sumproduct part that has me puzzled. I have used Sumproduct for a similar example and it worked fine, I get a little closer if I have the credits displayed vertically but I'm still getting #N/A errors so I thought I'd post here. I've only worked out the credits for the first record, once I get clarity for that I'll fill in the rest.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Well part of the reason the SUMPRODUCT formula you posted doesn't work could be that the criteria range, N6:N8, is empty.

Also, you can't use wildcards in SUMPRODUCT.
 
Upvote 0
I get a little closer if I have the credits displayed vertically
Because the range and the criteria both contain multiple cells they need opposite orientation.
Using ={SUMPRODUCT(1*(C2:J2=$O$2:$Q$2))} the comparisons are parallel, C2 is compared to O2, D2 to P2 and E2 to Q2. There is nothing in the second range to compare F2:J2 against which is why you get #N/A.

As @Norie has already said, you can't use wildcards with sumproduct criteria, to do what you are trying (without the wildcards) you would need to use the transpose function on one of the ranges, e.g.
{=SUMPRODUCT(1*(C2:J2=TRANSPOSE($O$2:$Q$2)))}

Although, as with most things there is a workaround

{=SUMPRODUCT(--ISNUMBER(SEARCH(TRANSPOSE($O$2:$Q$2),C2:J2)))}

Personally, I would stick with countif.
 
Upvote 0
Not sure what happened there, formula should be SUMPRODUCT(1*(C2:J2=$O$2:$Q$2)). This returns #N/A rather than 0.
 
Upvote 0
Thanks Norie and Jason for the explanation, I understand the limitations of SUMPRODUCT. The Jason workaround is nice and shows what can be done with SUMPRODUCT but COUNTIF is much easier.
I have read amongst the literature on Excel that SUMPRODUCT could be the single most useful function and so have invested some time in it but am beginning to have some doubts about the claims made about it.
 
Upvote 0
I have read amongst the literature on Excel that SUMPRODUCT could be the single most useful function
That probably was the case, common use of sumproduct was for counting or summing values in rows which meet multiple criteria. The introduction of sumifS and countifS in excel 2007 provided a more efficient alternative.

For a number of years such sumproduct formulas were still a necessity for people needing to maintain backwards compatibility with colleagues still using older versions of excel. There are still some complex formulas where sumproduct is the preferable method but they are getting fewer as more new functions are being added.
 
Upvote 0
Having taken a second look at your example, is this something that you can work with?
Book1
ABCDEFGHIJKLMNO
1ID no.CourseUnit1Unit2Unit3Unit4Unit5Unit6Unit7Unit8CreditsLevelCriteriaCredits
2ID 1DiplomaABC2020 56-PABC2040 28-NABC1110 30-NABC1090 61-CABC2690 61-CABC2090 28-NABC1110 50-PABC1040 61-C4DiplomaABC2*P2
3ID 2CertificateABC2020 36-NABC2090 81-HDABC2040 66-CABC2040 66-CABC2040 66-CABC2070 66-CABC2140 66-CABC2100 66-C7DiplomaABC2*C2
4ID 3DegreeABC2110 50-PABC1110 50-PABC1110 50-PABC1040 61-C0DiplomaABC2*D2
5ID 4DiplomaABC2110 50-PABC1110 50-PABC1110 50-PABC1040 61-C2CertificateABC2*P1
6CertificateABC2*C1
7CertificateABC2*D1
8CertificateABC10401
9DegreeABC2*C3
10DegreeABC2*D 3
Sheet1
Cell Formulas
RangeFormula
K2:K5K2=SUMPRODUCT(($M$2:$M$10=B2)*ISNUMBER(SEARCH($N$2:$N$10,C2:J2))*$O$2:$O$10)
 
Upvote 0
Thanks again Jason for the clarification regarding SUMPRODUCT, I'm wondering are there any examples where this function must be used because there are no other choices?

Anyway your last post is terrific, talk about inventive and efficient! I like your approach in a one-stop approach. The number of credits in column K are slightly out eg for student ID 1, they should receive 2 credits, ID 3 should receive 1 credit.
 
Upvote 0
Well part of the reason the SUMPRODUCT formula you posted doesn't work could be that the criteria range, N6:N8, is empty.

Also, you can't use wildcards in SUMPRODUCT.


Hii i have tied to use * card in sumproduct and it seems it is working fine

Book1
KLMNOP
4
5abc20PUNITABC1
620abcpunituu2
7
8
9
10*PUNIT
11
123
13
14
15
16
Sheet8
Cell Formulas
RangeFormula
M12M12=SUMPRODUCT(M5:M6,--ISNUMBER(SEARCH(O10,L5:L6)))



Is there any specific situation where it doesn't work. Please guide us for the constraint
 
Upvote 0
Thanks again Jason for the clarification regarding SUMPRODUCT, I'm wondering are there any examples where this function must be used because there are no other choices?
The method that I used in post 7 needs either sumproduct or sum with ctrl shift enter. The method doesn't work with sumifs as the wildcards would be in the wrong part of the formula.

Then there is the basic use of sumproduct for which it was originally intended, to multiply the values in each row or a range (product) then add the results of each row (sum) in a single formula.
The number of credits in column K are slightly out eg for student ID 1, they should receive 2 credits, ID 3 should receive 1 credit.
Not sure how you're seeing that based on the example, the numbers in column O denote the credits awarded, I just used 1, 2 and 3 for testing. As far as I can see all of the results in the sample match the criteria and the test values, ID1 receives 2 credits each for Unit1 and Unit5, ID3 has no units that match the criteria table.
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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