Conditional SUMPRODUCT Formula

brandonej

New Member
Joined
Aug 16, 2024
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello all. I need a formula that sums an array of values based on certain criteria.

The attached image is a simplified dataset for reference (the actual dataset is significantly larger).

Logic (for fruit): IF B4:B8 (item category) = oranges, OR apples, OR bananas, AND IF C15 (the year) matches C3:G3, return the SUMPRODUCT of the entire array C4:G8.

The logic is similar for veggies.

I tried to use IF AND OR SUMPRODUCT with no success.

Here is the formula I tried to use for fruit: =IF(AND(OR(B4:B8="Oranges","Apples","Bananas"),C15=$C$3:$G$3),SUMPRODUCT($C$4:$G$8))
 

Attachments

  • Conditional SUMPRODUCT Formula Example.png
    Conditional SUMPRODUCT Formula Example.png
    33.5 KB · Views: 13

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about:

Book1
ABCDEFGHIJ
1
2YearFruitVeggies
312345OrangesLettuce
4Oranges5101055ApplesCelery
5Apples24426Bananas
6Bananas46464
7Lettuce1020201020
8Celery1010201010
9
10
11
12
13TOTAL GROWN
14Year
1512345
16Fruit1120181315
17Veggies2030402030
18
Sheet9
Cell Formulas
RangeFormula
C16:G17C16=SUM(C$4:C$8*COUNTIF(INDEX($I$3:$J$10,0,MATCH($B16,$I$2:$J$2,0)),$B$4:$B$8))


I made a table for the fruits and veggies to make it easy to update.
 
Upvote 0
How about:

Book1
ABCDEFGHIJ
1
2YearFruitVeggies
312345OrangesLettuce
4Oranges5101055ApplesCelery
5Apples24426Bananas
6Bananas46464
7Lettuce1020201020
8Celery1010201010
9
10
11
12
13TOTAL GROWN
14Year
1512345
16Fruit1120181315
17Veggies2030402030
18
Sheet9
Cell Formulas
RangeFormula
C16:G17C16=SUM(C$4:C$8*COUNTIF(INDEX($I$3:$J$10,0,MATCH($B16,$I$2:$J$2,0)),$B$4:$B$8))


I made a table for the fruits and veggies to make it easy to update.
Thank you for your help. However, that solution might not work for the larger dataset I referenced in my post.

I should've added that I need a solution that works even if the fruits and veggies data is more granular (e.g., monthly).

(See snapshot for reference.)
 

Attachments

  • Conditional SUMPRODUCT Formula Example 2.png
    Conditional SUMPRODUCT Formula Example 2.png
    28.2 KB · Views: 8
Upvote 0
That's a risk if you simplify your data too much, the results might not be valid to your entire data. In this case, it's not too hard to adapt:

Book1
ABCDEFGHIJKLM
1
2
3Year1111122222
4Month1234512345
5Oranges510105514102085
6Apples2442623141414
7Bananas464642167173
8Lettuce10202010209121189
9Celery1010201010516201317
10
11
12
13TOTAL GROWN
14Year
1512345
16Fruit77149000
17Veggies140120000
18
19
20FruitVeggies
21OrangesLettuce
22ApplesCelery
23Bananas
24
Sheet9
Cell Formulas
RangeFormula
C16:G17C16=SUM($C$5:$L$9*COUNTIF(INDEX($B$21:$C$28,0,MATCH($B16,$B$20:$C$20,0)),$B$5:$B$9)*($C$3:$L$3=C$15))
 
Upvote 1
Solution

Forum statistics

Threads
1,224,929
Messages
6,181,814
Members
453,067
Latest member
mdiz777

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