Multiple criteria for SUMIFS

Chicken6

New Member
Joined
Dec 30, 2012
Messages
15
Hello all!

I am attempting to use SUMIFS to sum a column. However all the examples I have Googled have single criterion.

I have included a sample of my dataset below. Each subject has 9 rows (for various reasons) and I have included two of the subjects (300 and 301).

I need to sum the CLASS_wtmean (a weighted mean calculated from the CLASS column) for each subject. But only three of the values. Specifically the CLASS_sum = (Order = 1 and dataset = "all") + (Order = 2 and dataset = "all") + (Order = 3 and dataset = "prefail").

In the example below the answer for the CLASS_sum for subject 300 would be 0.661 (0.249 + 0.322 + 0.090).
For subject 301 it would be 0.899. I have repeated the answer for each row of a subject as I use R to subset various rows afterwards. I want to create a formula for the CLASS_sum column that I can drag down for the rest of the dataset!

I have tried using SUMIFS but came to a grinding halt when I realised I need to have more than one column criteria.
<code style="font-family: monospace, serif;">SUMIFS(sumrange,criteriarange1,criteria1[,criteriarange2,criteria2[,...]])</code>

=SUMIFS(AB236:AB244, D236:D244=1 AND F236:F244="all",... Not sure where to go from here :(. I am not sure if you can use 'and' in a SUMIFS() formula.

My formula experience has been pretty much limited to SUM and rudimentary IF statements. Any clues would be greatly appreciated!




ADEFAAABAC
1subjOrderScenariodatasetCLASSCLASS_wtmeanCLASS_sum
2363003Coall0.6700.0960.661
2373003Copostfail0.690NA0.661
2383003Coprefail0.6300.0900.661
2393001Exall0.5800.2490.661
2403001Expostfail0.500NA0.661
2413001Exprefail0.7500.3220.661
2423002Reall0.7500.3220.661
2433002Repostfail0.750NA0.661
2443002Reprefail0.7500.3220.661
2453012Coall0.9200.3950.899
2463012Copostfail0.880NA0.899
2473012Coprefail1.0000.4290.899
2483013Exall0.9200.1320.899
2493013Expostfail0.940NA0.899
2503013Exprefail0.8800.1260.899
2513011Reall0.8800.3780.899
2523011Repostfail0.810NA0.899
2533011Reprefail1.0000.4290.899
254302

<tbody>
</tbody>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This should work for you:
Code:
=SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,1,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,2,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,3,$D$2:$D$1000,"prefail")
My original version only printed the total on the first line of each subject. Assuming your data starts in line 2:
Code:
=IF(MATCH(A236,$A$2:$A$1000,0)+ROW($A$2)-1<>ROW(A236),"",SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,1,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,2,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,3,$D$2:$D$1000,"prefail"))
Note that both of those formulas reference A236, so paste the formula in AC236, hit enter, then copy it to the rest of the column. They also have a maximum range of 1000, which you'll need to verify.
 
Upvote 0
Try,

=SUM(SUMIFS(AB236:AB254,A236:A254,300,D236:D254,{1,2},F236:F254,"all"))+SUMIFS(AB236:AB254,A236:A254,300,D236:D254,3,F236:F254,"prefail")

Remark :
The above formula subject in column A use 300, the result return 0.661. And if the subject in column A change to 301 it would be 0.899


Regards
 
Last edited:
Upvote 0
This should work for you:
Code:
=SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,1,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,2,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,3,$D$2:$D$1000,"prefail")
My original version only printed the total on the first line of each subject. Assuming your data starts in line 2:
Code:
=IF(MATCH(A236,$A$2:$A$1000,0)+ROW($A$2)-1<>ROW(A236),"",SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,1,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,2,$D$2:$D$1000,"all")+SUMIFS($F$2:$F$1000,$A$2:$A$1000,A236,$B$2:$B$1000,3,$D$2:$D$1000,"prefail"))
Note that both of those formulas reference A236, so paste the formula in AC236, hit enter, then copy it to the rest of the column. They also have a maximum range of 1000, which you'll need to verify.


Thank you very very much Eric! This worked :) I changed the cell range to just the one subject rather than the whole lot, and made the cells underneath equal that cell (I changed the first criterion range to AB rather than F columns too):

=SUMIFS(AB236:AB244, D236:D244,1,F236:F244,"all") + SUMIFS(AB236:AB244, D236:D244,2,F236:F244,"all")+SUMIFS(AB236:AB244,D236:D244,3,F236:F244,"prefail")

I have tested it with manual calculations and all good. You have saved me days of pain. Thank you!

 
Upvote 0
this also worked! I have seen the curly brackets used but wasn't sure of how they could be applied. Thanks BoscoYip.
 
Upvote 0
this also worked! I have seen the curly brackets used but wasn't sure of how they could be applied. Thanks BoscoYip.

The constant array {1,2} in the formula :

=SUM(SUMIFS(AB236:AB254,A236:A254,300,D236:D254, {1,2},F236:F254,"all")) is equal to (subject = 3 + Order = 1 and dataset = "all") + (subject = 3 + Order = 2 and dataset = "all")
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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