Median Calculation in Excel with Conditions - excel-formula

I am having trouble getting the following Excel formula to work. I think I am having an issue with my parenthesis. I am trying to take the median based off of 3 conditions. The last condition is a date range.
=MEDIAN(IF($G$3:$G$458=$K$3,IF($A$3:$A$458=M$3,IF(AND($E$3:$E$458>DATEVALUE("1/1/2014"),$E$3:$E$458<DATEVALUE("12/31/2014")),$H$3:$H$458))))

Your formula is correct you just need to hit CTRL+SHIFT+ENTER to make it an array formula.
Whenever you apply a formula (E3:E458=$E$458) to a range within one cell you need to make the calculation an array formula.

Related

Excel error - formula contains SUMIFS, and OR and Some Dates

I'm trying to get the formula below to work but I'm getting a #Spill! error
Adding Feb-20 works fine but adding the Mar-20 appears to break something.
=SUMIFS(Calcs!CZ:CZ,Calcs!$AL:$AL,{"Feb-20","Mar-20"},Calcs!$AJ:$AJ,"<>"&"")
I think that due to the later additions into excel, the modern interpretation of array criteria is that for each of your criteria, it produces an array of answers, so you are getting #Spill! because excel is trying to make your single celled sumifs formula spill into two cells, each using a single criteria of your array criteria:
one cell having this formula in:
=SUMIFS(Calcs!CZ:CZ,Calcs!$AL:$AL,"Feb-20",Calcs!$AJ:$AJ,"<>"&"")
and the other cell having this formula in:
=SUMIFS(Calcs!CZ:CZ,Calcs!$AL:$AL,"Mar-20",Calcs!$AJ:$AJ,"<>"&"")
The spill error is likely because the cell adjacent to the cell you are performing this sumifs formula in has something in it.
documentation on this here:
https://www.excelcampus.com/functions/dynamic-array-formulas-spill-ranges/
My suggestion therefore is to simply wrap your current formula with a final sum, like this:
=SUM(SUMIFS(Calcs!CZ:CZ,Calcs!$AL:$AL,{"Feb-20","Mar-20"},Calcs!$AJ:$AJ,"<>"&""))

How to find minimum value on range of cells that are greater than 1 in excel?

In Excel, I have a range of cells (AD2:AH29), and I want to find the minimum value for these cells. However, I only want to consider cells for which the value is greater than 1.
I tried using the following but I can't quite get the formula right, since I don't know how to tell excel to only consider the cells where the value is greater than 1:
MIN(IF(">1"),AD2:AH29)
MIN(IF(">1",AD2:AH29))
It is an array formula:
=MIN(IF(AD2:AH29>1,AD2:AH29))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
OR
You can use AGGREGATE() and avoid the necessity of using Ctrl-Shift-Enter:
=AGGREGATE(15,6,AD2:AH29/(AD2:AH29>1),1)

COUNTIFS function not working with single cell range

I'm having an issue with COUNTIFS function in excel, i have a very large formula that I was getting an error on, but I have slowly taken the formula apart to a smaller subset and identified the issue I'm having. Excel won't use COUNTIFS correctly when the criteria range is one cell. Here's the formula I'm using:
=COUNTIFS(A7:A7,1,Sheet1!F:F,$A$9,Sheet2!S:S,$B$8)
Whenever I take the first criteria out "A7:A7,1" my formula returns a value, without it I receive #VALUE! error. Can you not use one cell as the criteria for CountIFS? I've also tried replacing "A7:A7" with just "A7" or "$A$7". The first criteria is the most important, because i'm going to be using a listbox for that cell that will change the values in my range for interactive graphs..
The ranges in the countifs need to be the same size.
Wrap the COUNTIFS() in a IF:
=IF(A7=1,COUNTIFS(Sheet1!F:F,$A$9,Sheet2!S:S,$B$8),0)

Excel: Sumproduct not working when blanks in data set

I am trying to get a sumproduct function to average a column based on criteria in prior adjacent columns.
The column i am trying to average is calculated from a formula that has an IFERROR to return a blank if there is an error.
=IFERROR(A5*B3,"")
some of the cells in that column containt the blank generated by the if error statement, my sumproduct is giving a #value error when it tries to average the range with the blank. I want it treated as nothing not as 0
Is there anyway around this or should I try to recreate my sumproduct using some sort of averageifs function?
This is the sumproduct in question:
=SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118))/SUMPRODUCT((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10))
Try this array formula instead:
=AVERAGE(IF((Data!$KM$7:$OV$7=C$7)*(Data!$KM$9:$OV$118>=$B10)*(Data!$KM$9:$OV$118<=$A10)*(Data!$BLW$9:$BLW$118<>""),Data!$BLW$9:$BLW$118))
Being an array it needs to be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done properly excel will put {} around the formula.
The reason SUMPRODUCT will not work is it tries to multiply a string, albeit an empty string but a string none the less, with numbers, which will throw an error.
The array formula ignores all the empty string cells and skips them.
The formula =IFERROR(A5*B3,"") puts a "" in the cell. This is not a value, so formulas using this cell won't work. You need to turn it to a numeric value even though it is blank
Use =value(IFERROR(A5*B3,""))
=SUMPRODUCT(P10,M10,L14,L13). This could be easy. We have to write what we want to do rather it is sum, product, division or subtract

conditional median in excel worksheet

I want to calculate a conditional median.
The formula =MEDIAN(K3851:K4792;$O3851:$O4792) works.
The step I cannot make is the one where the calculation
is restricted to when K<1. It seems easy enough, but I get
the error code "#NAME?".
I would greatly appreciate your help.
You can use an array formula¹ to set up the condition. The array formula will pick up blank cells so you will have to add a condition to discard them as well.
=MEDIAN(IF(K3851:K4792<1; IF(K3851:K4792<>""; $O3851:$O4792)))
PROOF
        
¹ Array formulas need to be finalized with Ctrl+Shift+Enter↵. Once entered into the first cell correctly, they can be filled or copied down or right just like any other formula. See Guidelines and examples of array formulas for more information.

Resources