Puzzled by Excel SumProduct formula using (LEFT()

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,275
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good evening - planespotting records time!

The following formula correctly returns a number value of 3286:
=SUMPRODUCT(--(Col_DB_Prefix="G"),--(Col_DB_Category="British Private"),--(Col_DB_Prefix=L5))
but when I amend the third part of the formula to:
=SUMPRODUCT(--(Col_DB_Prefix="G"),--(Col_DB_Category="British Private"),--(LEFT(Col_DB_Prefix,2)=L5))
it returns #VALUE!
I can't for the life of me see what I'm doing wrong, but it might have something to do with the fact that I've been working from home for the last billion years!
Can any of you good folk see where I'm going wrong, please?
Cheers
Pete
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Pete,

Not sure but this strikes me as odd:
- Col_DB_Prefix="G" => Col_DB_Prefix is a single letter
- LEFT(Col_DB_Prefix,2) => Should return a string of length 2

It can't be both... at the same time. So why evaluate Col_DB_Prefix twice?

EDIT: another thought: LEFT ( ) does it accept an array argument? Confirm formula with CSE?
 
Last edited:
Upvote 0
Sorry, possibly a bit misleading...
Assuming cell L5 = "AVMH"
=SUMPRODUCT(--(Col_DB_Prefix="G"),--(Col_DB_Category="British Commercial"),--(Col_DB_Reg=L5))
returns 1, because there is only one cell in Col_DB_Reg that equals "AVMH"

I would also therefore expect:
=SUMPRODUCT(--(Col_DB_Prefix="G"),--(Col_DB_Category="British Commercial"),--(LEFT(Col_DB_Reg,2)="AV"))
to return 17, because there are 17 cells in Col_DB_Reg that begin with "AA", but it doesn't, it returns #VALUE!

With regard to your final comment,
"Confirm formula with CSE?", to what are you referring, please?
Thanks
Pete
 
Upvote 0
Sorted. Col_DB_Reg contains both numeric and string values. As soon as I deleted all the rows with numerical values. the formula calculated correctly.
I need another condition that excludes any values in Col_DB_Reg that are numbers. Something like:
=SUMPRODUCT(--(Col_DB_Prefix="G"),--(Col_DB_Category="British Private"),--(NOT(ISNUMBER(Col_DB_Reg))),--(LEFT(Col_DB_Reg,2)="AV"))
(which also returns #VALUE!)
Cheers
Pete
 
Upvote 0
It was easier to convert all the numeric values in Col_DB_Reg to labels, so I did that - problem solved. Still curious as to whether this could be accomplished via SUMPRODUCT, without having to change my source data, though!
Thanks
Pete
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,237
Members
448,555
Latest member
RobertJones1986

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