# Puzzled by Excel SumProduct formula using (LEFT()

#### NewOrderFac33

##### Well-known Member
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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

#### GraH

##### Well-known Member
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
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
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
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

Replies
6
Views
114
Replies
6
Views
190
Replies
3
Views
525
Replies
6
Views
293
Replies
4
Views
202