I'd like to take the AVERAGEIF of a range, more specifically calculate the average using the values in their absolute form.
Therefore I'd like to do a function such as: =AVERAGEIF(W13:W1553;"42018";ABS(O13:O1553))
But this won't work in Excel...
Can someone help? Thank you!
AVERAGEIF will not allow the manipulation of the ranges. One would need to use an array formula:
=AVERAGE(IF((W13:W1553=42018)*(O13:O1553<>""));ABS(O13:O1553)))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one does not want to use an array formula, one can use a helper column to get the ABS of the number row.
In Z13 put =ABS(O13) then copy down to row 1553 and then use AVERAGEIF
=AVERAGEIF(W13:W1553;"42018";Z13:Z1553))
Related
=SUMIF(A1:A14, "102000*", B1:B14)
Why it cannot filter the value starts with 10200?
An array (CSE) formula solves the issue:
How it works:
Suppose you want to add numbers like 1020001, then enter it as criteria in cell D74, and use this formula.
{=SUM((B74:B82)*(--(A74:A82=D74)))}
If you have more criteria, like I've shown in D74 & in E74, then use this one in C74.
{=SUM((B74:B82)*(--(A74:A82=D74)+(--(A74:A82=E74))))}
N.B.
Finish formula with Ctrl+Shift+Enter.
You may adjust cell references in the formula as needed.
You are better off creating a new column using the formula
left(a1,5)
Then base the sumif off that new column.
If you want to count the number of occurences, you can use
=SUMPRODUCT(--(--LEFT(A1:A7,5)=10200))
and if you actually want to sum values, use
=SUMPRODUCT(--(--LEFT(A1:A7,5)=10200)*(B1:B7))
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))))
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...
I know that a formula can be applied on a range of cells by utilizing an intermediate column, but can I directly specify a range in a formula somehow?
E.g., is it possible to do something like this, to get the sum of the results of dividing each cell in E12-E26 by each cell in C12-C26:
=SUM(E12/C12:E26/C26)
An answer, either positive or negative, would be accepted.
You can do what you are wanting to do with an Array formula or CSE formula (Different name for the same thing). To do this, enter:
=SUM(E12:E26/C12:C26)
Then, instead of hitting "Enter" on the keyboard use Ctrl+Shift+Enter (CSE). This will put squirrely brackets around the formula and will apply the division to each pair in the range and then sum the results.
You could also use =SUMPRODUCT() for this, which essentially acts like an array formula, but with the Ctrl+Shift+Enter nonsense:
=SUMPRODUCT((E12:E26)/(C12:C26))
Sumproduct is useful since it will do logic inside the parantheses first across an array/range of cells then sum up the results. You can pull of some cool stuff with the formula, but it's also a beast and cat get out of control pretty easily.
Is it possible to combine AND (or OR) statement criteria to avoid repeating a cell name?
For example, I want to see if cell C2 contains the any of the numbers 2,3,5,7, or 10. I want to avoid writing
IF(AND(C2=2,C2=3... etc.
and simplify it to an array of the numbers like
IF(AND(C2=[2,3,5,7,10]...
Unfortunately, I have a lot more than just 5 numbers to add so it's getting be very laborious. Anyone have an easier way than repeating the cell name=__ over and over?
You can use an "array constant" like this
=IF(OR(C2={2,3,5,7,10}),"Yes","No")
.....or for a large set of numbers you could put all the numbers in a cell range, e.g. Z2:Z100 and do the same
=IF(OR(C2=$Z$2:$Z$100),"Yes","No")
although when you use a range rather than an array constant the formula becomes an "array formula" so needs to be confirmed with CTRL+SHIFT+ENTER
perhaps better to use COUNTIF and avoid "array entering"...
=IF(COUNTIF($Z$2:$Z$100,C2)>0,"Yes","No")
=IF(ISERROR(MATCH(C2,{2,3,5,7,11},0)),"no","yes")
No need to enter this as an array formula. How it works: MATCH returns a #N/A! error if it can't find the lookup value in the lookup array. ISERROR catches this.
But as barry houdini suggests, you may want to put your numbers in some range e.g. Z1:Z5 instead of hard-coding them into your formula. So you would have this formula instead:
=IF(ISERROR(MATCH(C2,Z1:Z5,0)),"no","yes")