How to use COUNTIF or COUNTIFS with the LEFT function?
Example:
............COL B .......COL J
Row1...House #1.....Acme
Row2...House #1.....Acme
Row3...House #3.....Acme
Row4...House #5.....Acme
Row5...(blank).........Acme
Row6...(blank).........Acme
Row7...Joe..............Acme
Row8...House #7.....Acme
Count if B1:B8=“House” and J1:J8=“Acme”...The answer is 5. The actual table is 400 rows long, with multiple columns and combinations, but the above simplified version is the essence of the problem.
The LEFT function is necessary because (COUNTIF(B1:B8=“House” does not work because there is no B1:B8=“House”, as each term of “house” has a number, which CountIf will not count. But a LEFT(J1,5)="House" will work, because it eliminates anything after the word "House" if it appears.
Further, COUNTIF J1:J8= “Acme” will not work because it will count all instances of “Acme”, which is not correct.
I’ve tried:
=SUMPRODUCT((LEFT(B1:B8,5)=“House"),(J1:J8=“Acme”),B1:B8)
and
=SUM(IF(LEFT(B1:B8,5))="House",J1:J8,0))
and
= COUNTIFS(J1:J8,”Acme”,(IF(LEFT(B1,8)=“House",1,0))
...and a variety of other variations. I just can’t seem to fit “LEFT” into the SUM or COUNT functions.
Importantly, these are words that are being counted, not numbers. If the correct combination (“House” + “Acme”) appears, that’s “1”, so it is just straight addition.
Any help would be greatly appreciated. This is for a church project, and if I can get this formula going, it will really help manage some volunteer projects.
Thanks!
Example:
............COL B .......COL J
Row1...House #1.....Acme
Row2...House #1.....Acme
Row3...House #3.....Acme
Row4...House #5.....Acme
Row5...(blank).........Acme
Row6...(blank).........Acme
Row7...Joe..............Acme
Row8...House #7.....Acme
Count if B1:B8=“House” and J1:J8=“Acme”...The answer is 5. The actual table is 400 rows long, with multiple columns and combinations, but the above simplified version is the essence of the problem.
The LEFT function is necessary because (COUNTIF(B1:B8=“House” does not work because there is no B1:B8=“House”, as each term of “house” has a number, which CountIf will not count. But a LEFT(J1,5)="House" will work, because it eliminates anything after the word "House" if it appears.
Further, COUNTIF J1:J8= “Acme” will not work because it will count all instances of “Acme”, which is not correct.
I’ve tried:
=SUMPRODUCT((LEFT(B1:B8,5)=“House"),(J1:J8=“Acme”),B1:B8)
and
=SUM(IF(LEFT(B1:B8,5))="House",J1:J8,0))
and
= COUNTIFS(J1:J8,”Acme”,(IF(LEFT(B1,8)=“House",1,0))
...and a variety of other variations. I just can’t seem to fit “LEFT” into the SUM or COUNT functions.
Importantly, these are words that are being counted, not numbers. If the correct combination (“House” + “Acme”) appears, that’s “1”, so it is just straight addition.
Any help would be greatly appreciated. This is for a church project, and if I can get this formula going, it will really help manage some volunteer projects.
Thanks!