Combine Two Formulas - excel

I want to combine a formula that disregards cells where there is a 0 in order to average and also to disregard cells where there is an error such as DIV/0.
I have these two formulas which achieve either of these functions but not both. How would I combine them?
{=AVERAGE(IF(ISNUMBER(M2:P2),M2:P2))}
=AVERAGEIF(M2:P2,"<>0")

You would simply add the criterion of the second to the first:
=AVERAGE(IF(ISNUMBER(M2:P2)*(M2:P2<>0) ,M2:P2))
This is still an array formula and as such needs to be confirmed with Ctrl-Shift-Enter instead of Enter. If done properly then Excel will put {} around the formula.

you could use an if() to check for either condition then use the appropriate average function.
#Scott : better than mine...

Related

Excel AVERAGEIFS like formula which treats text as 0 and not ignore them

Is there anyway to use AVERAGEIF or a similar function that treats text value as 0 and not just ignore them. Something similar to AVERAGEA function, but with multiple criteria?
I saw a similar question here which wanted to treat blanks or empty cells as 0. The answer suggested to use array formulas to add 0 to it. Not sure if it holds for other texts as well.
If you do NOT want to count blanks, you can use:
=SUM(A1:A10)/COUNTA(A1:A10)
(If you wanted to count blanks, something like sum(rng)/rows(rng) would do it)
You can use a similar technique to include criteria for AVERAGEIF
For example, given:
If you want to average all the values in Column A where a is in Column B:
=SUMIF(B1:B10,"a",A1:A10)/COUNTIF(B1:B10,"a")
It would be similar to the other link:
=AVERAGE(IFERROR(--A1:A10,0))
It is an array formula and with Excel to confirm an array formula one must use Ctrl-Shift-Enter instead of Enter when exiting edit mode.
One Note: This will treat blanks as 0 also, so make sure it only refers to the data set desired.
Similar to Rohan's post, I personally would break it down to see how many strings are pushing down your average. But if you want it all in one cell:
That is an asterisk inside the double quotes
one cell: =SUM(E1:E10)/(COUNTIF(E1:E10,"")+COUNTIF(E1:E10,"<>*"))
break down:
Non-Numeric: COUNTIF(E1:E10,"*****")
Numeric: COUNTIF(E1:E10,"<>*")
spreadsheet link
1

Conditional AGGREGATE/Median in Excel 2010

I am currently trying to pull a median from a range of data that has two conditions. Essentially the equivalent of the below AVERAGEIFS(), which I have working fine.
The AVERAGEIFS():
=AVERAGEIFS(Analysis!$F:$F,Analysis!$F:$F,">=0",Analysis!$C:$C,Dashboard!C6,Analysis!$W:$W,Dashboard!B8)
I cannot figure a way to combine MEDIAN and IF(AND( to come up with a similar formula, but think AGGREGATE might be useful!
Any help or sanity checks are appreciated!
It's true that you can't do a conditional median with AGGREGATE function, not directly, but you can easily use function number 16 (PERCENTILE.INC) or function number 17 (QUARTILE.INC) with respectively k values of 0.5 and 2.
These functions allow arrays in AGGREGATE......and have the added advantage of automatically ignoring errors, so you can use this formula for the median with conditions
=AGGREGATE(17,6,Analysis!$F:$F/(Analysis!$C:$C=Dashboard!C6)/(Analysis!$W:$W=Dashboard!B8),2)
You are creating an Array formula with MEDIAN. So a couple of rules when using Array formulas:
Do not use full column References in Array type formula. Limit the references to the data set. We can do that automatically with $F$1:INDEX(F:F,MATCH(1E+99,F:F)) this will set the reference in Column F to F1 to the last row with a number in it.
AND() does not work in array formulas, either nest IF()s or use * between the Boolean test
The formula needs to be confirmed with Ctrl+Shift+Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
So the formula would be something like this:
=MEDIAN(IF((Analysis!$F$1:INDEX(Analysis!$F:$F,MATCH(1E+99,Analysis!$F:$F))>=0)*(Analysis!$C$1:INDEX(Analysis!$C:$C,MATCH(1E+99,Analysis!$F:$F))=Dashboard!C6)*(Analysis!$W$1:INDEX(Analysis!$W:$W,MATCH(1E+99,Analysis!$F:$F))=Dashboard!B8),Analysis!$F$1:INDEX(Analysis!$F:$F,MATCH(1E+99,Analysis!$F:$F))))

Index Match multiple criteria with one OR condition

I have the following index matchformula:
=IFERROR(INDEX($B:$B;(MATCH(1;($C:$C="Value1")*($D:$D=$F3)*($E:$E=OR("X";"Y";"Z"));0)));"")
however, I want $E:$E=OR("X";"Y";"Z") to be one of the conditions of the match: I want to see if E has one of these three values.
Currently it gives an error. How to achieve this condition in the match statement?
Thanks
I recommend restricting the ranges, using whole columns will make the formula slow......but try using ISNUMBER/MATCH for your OR, I.e.
=IFERROR(INDEX($B:$B;MATCH(1;($C:$C="Value1")*($D:$D=$F3)*ISNUMBER(MATCH($E:$E;{"X";"Y";"Z"};0));0));"")
Confirm with CTRL+SHIFT+ENTER
or you can try the following:
=IFERROR(INDEX($B:$B;(MATCH(1;($C:$C="Value1")*($D:$D=$F3)*(($E:$E="X")+($E:$E="Y")+($E:$E="Z"));0)));"")
this is an array formula, so press ctrl+shift+enter to calculate the formula.

Using SUMPRODUCT with TRANSPOSE

I'm trying to use TRANSPOSE inside SUMPRODUCT. What's wrong with my formula?
I use Excel 2013 if that matters.
Your formula is correct, you just need to press Crtl+Shift+Enter to confirm it and make it an array formula. In some cases SUMPRODUCT will sometimes automatically handle array treatment of arguments, but a TRANSPOSE argument apparently is not among them.
I'm not sure what result you want but would be interested to know whether:
=MMULT(D9:F9,D3:D5)
entered with Ctrl+Shift+Enter is such.

How do you do sumif with equation?

Basically, I want to do a SUMIF, but I need to enter an equation for sum_range parameter, so normally, to do a SUMIF, you write:
=SUMIF(CRITERIA_RANGE,CRITERIA,SUM_RANGE)
This is great, but what if I need to do some calculation in my summation? So for example:
=SUMIF(CRITERIA_RANGE,CRITERIA,COL1*COL2)
Is something like this possible?
SUMPRODUCT is commonly used in this case
Eg
=SUMPRODUCT((CRITERIA_RANGE=CRITERIA)*COL1*COL2)
A different answer (NOT FOR POINTS).
Explanation
The reason why you cannot use SUMIF in your scenario is because SUMIF cannot handle Arrays as sumproduct does and hence I would go with Chris's suggestion of using SUMPRODUCT
Alternative
Here is one more way to achieve what you want.
=SUM(IF(CRITERIA_RANGE=CRITERIA,COL1*COL2,""))
ScreenShot
Please note that this is an ARRAY FORMULA which means that instead of pressing ENTER, you have to press CTRL+SHIFT+ENTER

Resources