Add one condition to this formula...?

jaedmar

Board Regular
Joined
Feb 14, 2011
Messages
60
This is the formula that I currently use:

=IFERROR(SUMPRODUCT(SUMIF(INDIRECT("'"&sheetlist&"'!m15"),"FF",INDIRECT("'"&sheetlist&"'!m22")))/SUMPRODUCT(COUNTIF(INDIRECT("'"&sheetlist&"'!m15"),"FF")),"")

What it does is average the m22 cells on sheets in which m15=FF.

In addition to the condition that m15 must = FF, I want to add a second condition before averaging. I want to add the condition that m22 must be > 1.

How do I add that condition to the above formula?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This is the formula that I currently use:

=IFERROR(SUMPRODUCT(SUMIF(INDIRECT("'"&sheetlist&"'!m15"),"FF",INDIRECT("'"&sheetlist&"'!m22")))/SUMPRODUCT(COUNTIF(INDIRECT("'"&sheetlist&"'!m15"),"FF")),"")

What it does is average the m22 cells on sheets in which m15=FF.

In addition to the condition that m15 must = FF, I want to add a second condition before averaging. I want to add the condition that m22 must be > 1.

How do I add that condition to the above formula?

Try...
Code:
=IFERROR(SUMPRODUCT(SUMIFS(
     INDIRECT("'"&sheetlist&"'!m22"),
     INDIRECT("'"&sheetlist&"'!m22"),">1",
     INDIRECT("'"&sheetlist&"'!m15"),"FF"))/
   SUMPRODUCT(COUNTIFS(
     INDIRECT("'"&sheetlist&"'!m22"),">1",
     INDIRECT("'"&sheetlist&"'!m15"),"FF")),"")
 
Upvote 0
Thanks, that worked.

One more question. How would I add that same extra condition to the following formula (to make a total of three conditions):

=IFERROR(SUMPRODUCT(SUMIFS(INDIRECT("'"&sheetlist&"'!m22"),INDIRECT("'"&sheetlist&"'!m8"),">=35",INDIRECT("'"&sheetlist&"'!m8"),"<40"))/SUMPRODUCT(COUNTIFS(INDIRECT("'"&sheetlist&"'!m8"),">=35",INDIRECT("'"&sheetlist&"'!m8"),"<40")),"")

In order to get the average, three conditions must exist: m22 should be > 1, and the person's age in m8 should be >=35 but <40.
 
Upvote 0
Thanks, that worked.

One more question. How would I add that same extra condition to the following formula (to make a total of three conditions):

=IFERROR(SUMPRODUCT(SUMIFS(INDIRECT("'"&sheetlist&"'!m22"),INDIRECT("'"&sheetlist&"'!m8"),">=35",INDIRECT("'"&sheetlist&"'!m8"),"<40"))/SUMPRODUCT(COUNTIFS(INDIRECT("'"&sheetlist&"'!m8"),">=35",INDIRECT("'"&sheetlist&"'!m8"),"<40")),"")

In order to get the average, three conditions must exist: m22 should be > 1, and the person's age in m8 should be >=35 but <40.
Try this...

=IFERROR(SUMPRODUCT(SUMIFS(INDIRECT("'"&sheetlist&"'!M22"),INDIRECT("'"&sheetlist&"'!M22"),">1",INDIRECT("'"&sheetlist&"'!M8"),">=35",INDIRECT("'"&sheetlist&"'!M8"),"<40"))/SUMPRODUCT(COUNTIFS(INDIRECT("'"&sheetlist&"'!M22"),">1",INDIRECT("'"&sheetlist&"'!M8"),">=35",INDIRECT("'"&sheetlist&"'!M8"),"<40")),"")
 
Upvote 0
Thanks, that worked.

You are welcome.

One more question. How would I add that same extra condition to the following formula (to make a total of three conditions):

=IFERROR(SUMPRODUCT(SUMIFS(
INDIRECT("'"&sheetlist&"'!m22"),
INDIRECT("'"&sheetlist&"'!m8"),">=35",
INDIRECT("'"&sheetlist&"'!m8"),"<40"))/
SUMPRODUCT(COUNTIFS(
INDIRECT("'"&sheetlist&"'!m8"),">=35",
INDIRECT("'"&sheetlist&"'!m8"),"<40")),"")

In order to get the average, three conditions must exist: m22 should be > 1, and the person's age in m8 should be >=35 but <40.

You were almost there. I think you forgat to keep the expression INDIRECT("'"&sheetlist&"'!m22"),">1" in both the nominator and denomitor from the eaarlier SumIfs formula...

Code:
=IFERROR(SUMPRODUCT(SUMIFS(
     INDIRECT("'"&sheetlist&"'!m22"),
     INDIRECT("'"&sheetlist&"'!m22"),">1",
     INDIRECT("'"&sheetlist&"'!m8"),">=35",
     INDIRECT("'"&sheetlist&"'!m8"),"<40"))/
   SUMPRODUCT(COUNTIFS(
     INDIRECT("'"&sheetlist&"'!m22"),">1",
     INDIRECT("'"&sheetlist&"'!m8"),">=35",
     INDIRECT("'"&sheetlist&"'!m8"),"<40")),"")

I suppose the test INDIRECT("'"&sheetlist&"'!m15"),"FF" the earlier formula has is not needed!
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,462
Members
452,915
Latest member
hannnahheileen

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