Sumproduct where column headings and row values are criteria, including right function

ASTOCH

New Member
Joined
Apr 30, 2014
Messages
6
I received a massive file from a friend who has done extensive research and has been counting her results manually. We need to know for each subject (row) in the below example:
Case 1. How many LIVING objects e.g. Dog or Mouse the subject answered incorrectly. (Column B = "L" and Column C =1) and (Column F = "L" and Column G = 1).
Case 2. Same as above for NONLIVING objects. (Column D = "N" and Column E = 1).

I show case 2 just for illustrative purposes... If we solve case 1, we solve the total problem.

The file is huge so I am trying to be as efficient as possible by using something like:
=SUMPRODUCT(((Data!1:1="LivNonLiv")*(Data!2:2="L"))*((RIGHT(Data!1:1,3)="err")*(Data!2:2=1)))

I am able to get the correct results when I separate the formula:
=SUMPRODUCT((Data!1:1="LivNonLiv")*(Data!2:2="L")) returns the value 2 and
=SUMPRODUCT((RIGHT(Data!1:1,3)="err")*(Data!2:2=1)) returns the value 2 for subject 1

But then always get zero when I bring them together.

Col ACol BCol CCol DCol ECol FCol G
SubjectLivNonLivDogErrLivNonLivHouseErrLivNonLivMouseErr
1L1N0L1
2L0N0L1
3L1N1L0
4L0N1L0
5L0N1L0

<tbody>
</tbody>
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Care to post the expected value (count) for Case 1 and the same for Case 2?

Hi Aladin, thanks for the enquiry response. Here are the case values.

SubjectLivNonLivDogCatErrLivNonLivMountainHouseErrLivNonLivMouseErrCase 1Case 2
1L1N0L120
2L0N0L110
3L1N1L011
4L0N1L001
5L0N1L001

<tbody>
</tbody>
 
Upvote 0
Hi Aladin, thanks for the enquiry response. Here are the case values.

SubjectLivNonLivDogCatErrLivNonLivMountainHouseErrLivNonLivMouseErrCase 1Case 2
1L1N0L120
2L0N0L110
3L1N1L011
4L0N1L001
5L0N1L001

<tbody>
</tbody>

Thanks...

Can you work with the set up that follows?

In H2 enter and copy down:

=SUMPRODUCT(--($B2:$F2="L"),--($C2:$G2=1))

In I2 enter and copy down:

=SUMPRODUCT(--($B2:$F2="N"),--($C2:$G2=1))
 
Upvote 0
Hi Aladin,

Thank you for your suggestion but that will not solve the issue. I have pasted in an extract from the actual spreadsheet to explain why this will not work. But in summary, we can only count where LivNonLiv = "L" and the right 3 chars in the 5th column after = "err".

SubjIDDeskLivNonLivDeskLess2DeskGr2DeskQDeskTOTDeskErrDeskOtherPencilLivNonLivPencilLess2PencilGr2PencilQPencilTOTPencilErrPencilOtherPlantLivNonLivPlantLess2PlantGr2PlantQPlantTOTPlantErrPlantOtherBookstoreLivNonLivBookLess2BookGr2BookQBookTOTBookErrBookOtherWeedLivNonLivWeedLess2WeedGr2WeedQWeedTOTWeedErrWeedOtherYachtLivNonLivyachtLess2yachtGr2yachtQyachtTOTyachtErryachtOtherBirdLivNonLivBirdLess2BirdGr2BirdQBirdTOTBirdErrBirdOtherTreeLivNonLivTreeLess2TreeGr2TreeQTreeTOTTreeErrTreeOtherRaspberryLivNonLivRaspLess2RaspGr2RaspQRaspTOTRaspErrRaspOtherWriterLivNonLivWriterLess2WriterGr2WriterQWriterTOTWriterErrWriterOtherBinocularsLivNonLivBinoLess2BinoGr2BinoQBinoTOTBinoErrBinoOtherKneeLivNonLivKneeLess2KneeGr2KneeQKneeTOTKneeErrKneeOtherHarmonicaLivNonLivHarmLess2HarmGr2HarmQHarmTOTHarmErrHarmOtherHostessLivNonLivHostLess2HostGr2HostQHostTOTHostErrHostOtherStickerLivNonLivStickerLess2StickerGr2StickerQStickerTOTStickerErrStickerOtherShirtLivNonLivShirtLess2ShirtGr2ShirtQ
123484NL100000150NL10000088L10000078NL100000353L01010lawn141NL100000318L010100297L01010066NL100000113L100000104NL100000106L100000250NL010100138L100000147NL100000556NL010
15123559NL1000001970NL01010sandwich, fruit, wine, cheese37L10000059NL100000419L01010shrubs57NL1000001193L01010mockingbird, minabird85L10000060NL10000069L10000053NL10000057L100000116NL10000072L10000056NL10000088NL100
2346297NL10000053NL100000125L100000130NL100000351L01010065NL100000122L100000163L100000100NL10000050L100000147NL10000050L100000403NL010100116L10000072NL100000103NL100
2345156NL10000047NL10000063L10000075NL10000084L10000059NL100000219L01010085L10000059NL10000044L10000063NL10000053L10000056NL10000091L10000075NL10000081NL100
12341597NL100000109NL10000047L10000053NL10000087L10000062NL100000175L100000162L10000047NL10000084L10000060NL10000034L100000125NL10000084L10000072NL10000094NL100

<tbody>
</tbody>
 
Upvote 0
Hi Aladin,

After reading my last post i realized it would be confusing. To clarify, the formula should count:
where LivNonLiv = "L" and
where the 5th column after (should be where right 3 chars is "err") = "1"

So, the sumproduct formula needs to see 4 conditions structured like:
1. Where the column heading is LivNonLiv and
2. where the row value = "L"
and
3. where the right 3 characters of the column heading = "err" and
4. where the row value =1

Thanks again



Hopefully this clarifies.
 
Upvote 0
Hope you can work with what follows...

L >>

=SUMPRODUCT(--(C2:DS2="L"),--(H2:DX2=1))

NL >>

=SUMPRODUCT(--(C2:DS2="NL"),--(H2:DX2=1))
 
Upvote 0

Forum statistics

Threads
1,215,822
Messages
6,127,061
Members
449,357
Latest member
donna_koenig

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