Puzzled by Excel SumProduct formula using (LEFT()

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,255
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
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

GraH

Well-known Member
Joined
Mar 22, 2020
Messages
613
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
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:

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,255
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
 

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,255
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
 

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,255
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
 

Watch MrExcel Video

Forum statistics

Threads
1,114,422
Messages
5,547,834
Members
410,813
Latest member
Vhinzvirgo
Top