Average not working with indirect formula and blank values - excel

I have this formula:
=IFERROR(
(
(
IFERROR(INDIRECT($A6&"!$E$15");"")
+IFERROR(INDIRECT($A6&"!$E$29");"")
+IFERROR(INDIRECT($A6&"!$E$43");"")
+IFERROR(INDIRECT($A6&"!$E$57");"")
+IFERROR(INDIRECT($A6&"!$E$71");"")
+IFERROR(INDIRECT($A6&"!$E$84");"")
)
/6);"")
When any of these IDIRECTS return a blank value, I get an #VALUE! error (without the first IFERROR). Each individual line works just fine, and when putting them in cells individually, I can average them fine. If I remove the /6 part of this formula however, and wrap the lines with an AVERAGE-formula, I get the #VALUE! error also.
How can I proceed?
EDIT, SOLUTION FOUND (Thanks Mrig):
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A7&"!$E$15"));INDIRECT($A7&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$29"));INDIRECT($A7&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$43"));INDIRECT($A7&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$57"));INDIRECT($A7&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$71"));INDIRECT($A7&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$84"));INDIRECT($A7&"!$E$84");0)
)/
(
COUNTIF(INDIRECT($A7&"!$E$15");">=0")
+COUNTIF(INDIRECT($A7&"!$E$29");">=0")
+COUNTIF(INDIRECT($A7&"!$E$43");">=0")
+COUNTIF(INDIRECT($A7&"!$E$57");">=0")
+COUNTIF(INDIRECT($A7&"!$E$71");">=0")
+COUNTIF(INDIRECT($A7&"!$E$82");">=0")
)
);"")
The COUNTIF's bascially replaces the number "6" in the original code, and checks which of the INSNUMER's (instead of IFERROR's) that isn't blanks, so anything that's 0% or higher (actual value) will be counted, to get to the true average.

Using the suggestions above in the comments, you can use IF(ISNUMBER()) instead of IFERROR()
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A6&"!$E$15"));INDIRECT($A6&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$29"));INDIRECT($A6&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$43"));INDIRECT($A6&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$57"));INDIRECT($A6&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$71"));INDIRECT($A6&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$84"));INDIRECT($A6&"!$E$84");0)
)/6);"")

I started off thinking that your 'stagger' was 14 rows so I went with this array formula:
=AVERAGE(IF(MOD(ROW(E15:E84), 14)=1, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
... but your 'stagger' is not a consistent 14 rows; the last gap is 13 rows so I modified it to this:
=AVERAGE(IF(ROW(15:84)={15,29,43,57,71,84}, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
That produces a true average without zero substitution on blank cells while discarding text values.

Related

How/which formula to use, to show combine text results for false condition (for pending task reporting usage)?

Wanted to check if CONCATENATE is the one to use (not sure if my excel has TEXTJOIN), and how to show just the text that has empty value in the cells.
For example in my attachment below, I want the intended result shown like in B2 and B3, where the texts shown with delimiter, when the values are false (empty).
If I were to use CONCATENATE like in Row 10 and Row 11, it's rather manual and it only capture "positive values" as in non-blank cells.
Purpose: To show pending tasks (empty/blank status cells)
Use MID with CONCATENATED IFS:
=MID(IF(C2="","/"&$C$1,"")&IF(D2="","/"&$D$1,"")&IF(E2="","/"&$E$1,"")&IF(F2="","/"&$F$1,"")&IF(GC2="","/"&$G$1,"")&IF(H2="","/"&$H$1,""),2,999)
I would use TEXJOIN and FILTER if you have the newest version of Excel.
For example: =TEXTJOIN("/",1,FILTER($E$2:$I$2, ISBLANK(E3:I3)))
EDIT: For older versions, a temporary workaround is as follows:
make a temporary array the same size as your original dataframe where each value is determined by a formula such as =IF(ISBLANK(E3), E$2&"/","")
Use something like =LEFT(CONCAT(E15:J15), LEN(CONCAT(E15:J15))-1) to get the desired result (where E15:J15 is where I elected to store the first row of the temporary array created in step 1).
I am not sure of your Excel version, but I think this would work in older versions (formatted for readability - will work if you paste it directly into cell B2 and copy down):
=LEFT(CONCAT( INDEX( CHOOSE({1;2;3},$C$1:$H$1,{"/","/","/","/","/","/"},{"","","","","",""}),
INDEX( IF(ISBLANK(C2:H2),{1;2},{3;3}),
MOD(COLUMN(A1:INDEX(1:1,,12))-1,2)+1,
(COLUMN(A1:INDEX(1:1,,12))-1)/2+1 ),
(COLUMN(A1:INDEX(1:1,,12))-1)/2+1 ) ),
SUM(7*ISBLANK(C2:H2))-1 )
Notes
As this is an array formula, you may have to enter it with CTRL + SHIFT + ENTER with an older version of Excel.
The stat labels must all have a length of 6 characters as shown in your post. If not, then they must at least have the same length and the last line SUM(7*ISBLANK(C2:H2))-1 must be changed to replace the 7 with the string length + 1, e.g. a length of 9 would be SUM(10*ISBLANK(C2:H2))-1.
If they don't have the same length, the LEFT( can be removed along with the SUM(10*ISBLANK(C2:H2))-1) at the end. You will end up having a trailing / delimiter at the end. You could fix that for the case of stat F being the last part by changing {"/","/","/","/","/","/"} to {"/","/","/","/","/",""}, but the other cases would still have a trailing /. Another approach is much more complex, but the component SUM(10*ISBLANK(C2:H2))-1) could be shaped to identify what to cut off or maybe a helper column could be built - in any case, let's hope your situation is that the stat labels all have the same length.
The delimiter "/" can be changed, but must always be a single character. If not, then then last line must be changed to SUM( [label length + delimiter length] *ISBLANK(C2:H2))-1.
This formula is fixed to 6 stat columns. If you need for it to accommodate more, it is possible by extending the {"/","/","/","/","/","/"} and {"","","","","",""} (one element for each new column) and replacing every 12 with 2 times the number of columns. Also, obviously, the references $C$1:$H$1 and C1:H2 must be changed to read in your new columns.

Can't find the right formula in Excel

I have 3 conditions based on this table: https://i.stack.imgur.com/GAeT0.png
Conditions are:
In column "Stadiu" (starting from D5) should type:
RIDICATA if the number from Populatie is > 1000 and the column Eveniment has Mondiala in it
MEDIE if the number from Populatie is > 500 or <= 1000 and the column Eveniment has Mondiala
MEDIE if the number from Populatie is > 500 and the column Eveniment has Internationala
SLABA = rest
I tried this formula:
=IF(AND(C5>1000;FIND("Mondiala";A5));"ridicata";IF(AND(C5>500;C5<=1000;FIND("Mondiala";A5));"medie";IF(AND(C5>500;FIND("Internationala";A5));"medie";IF(AND(C5<500);"slaba"))))
but it doesn't work.
I am new to Excel, so I hope you guys can help me what I am doing wrong. Thanks!
When evaluating the formula, anywhere that the FIND function doesn't find the string you're searching for, it returns a #VALUE error instead of 0 or FALSE. That's causing the whole formula to fail in those circumstances, so you need to handle those cases with IFERROR.
In addition, your nesting wasn't quite correct. You did not have an ELSE result for cases where all three tests failed. The following formula should return the expected results based on your criteria provided:
=IF(AND(C5>1000;IFERROR(FIND("Mondiala";A5);0));"Ridicata";IF(OR(AND(C5>500;C5<=1000;IFERROR(FIND("Mondiala";A5);0));AND(C5>500;IFERROR(FIND("Internationala";A5);0)));"Medie";"Slaba"))
Might be a little easier to relate it to your test criteria by spreading it out into sections:
=IF(
AND(
C5>1000;
IFERROR(FIND("Mondiala";A5);0)
);
"Ridicata";
IF(
OR(
AND(
C5>500;
C5<=1000;
IFERROR(FIND("Mondiala";A5);0)
);
AND(
C5>500;
IFERROR(FIND("Internationala";A5);0)
)
);
"Medie";
"Slaba"
)
)

Calculating Median Using Aggregate

If have the following function that is used to calculate SMALL:
=IFERROR(AGGREGATE(15; 6; Table5[Salary]/(Table5[Letter]="F") /(Table5[Level]=B2) /(Table5[[Title ]]=A2); 1); "-")
Which works perfectly fine when the first parameter is 15 (SMALL) or 14 (Large). But if I try to calculate the median ( replacing 15 with 12 ) the error value "-" is returned. Any ideas?
The median does not accept an array entry, it must be 14 or higher in the AGGREGATE to accept array entry.
You will need to use MEDIAN(IF()) as an array formula:
=IFERROR(MEDIAN(IF((Table5[Letter]="F")*(Table5[Level]=B2)*(Table5[[Title ]]=A2);Table5[Salary]));"-")
Being an array formula it needs to be confirmed with Ctrl-
Shift-Enter instead of Enter when exiting edit mode. If done correctly Excel will put {} around the formula.

IF(AND statement with multiple criterias

I am trying to write a formula to include multiple criteria and can't seem to get it right.
The formula works as is however I need to include "SHOT10","SHOT20", "SH15" and "SH20"
=IF(AND(C5194="SHOT15",H5194="",I5194=""),E5194,"")
Can someone assist me with modifying the above formula?
The AND(C5194="SHOT15",H5194="",I5194="") is equivalent to saying:
C5194="SHOT15" And H5194="" And 15194=""
So what you have in VBA code is:
If C5194="SHOT15" And H5194="" And 15194="" Then
ActiveCell = E5194
Else
ActiveCell = ""
End
You can use AND( and OR( to specify different parameters.
For example, If I want to pickup 3 different values in 'A1', but make sure that 'B1' and 'C1' are blank, I can use:
=IF(AND(OR(A1="A",A1="B",A1="C"),B1="",C1=""),"True","False")
So in your case specifically:
The issue now is that I now need to also consider SHOT10, SHOT20, SH15 and SH20 as well. Meaning that if either SHOT15, SHOT10, SHOT20, SH15 or SH20 appears in C5194 and H5194 is blank and I5194 is also blank then return the value of E5194 else return blank. The key is that all the conditions must be met for the value of E5194 be returned
Your formula becomes:
=IF(AND(OR(C5194="SHOT15",C5194="SHOT10",C5194="SHOT20",C5194="SH15",C5194="SH20"),H5194="",I5194=""),E5194,"")
Edit: Shorten Using an array constant per barry houdini:
=IF(AND(OR(C5194={"SHOT15","SHOT10","SHOT20","SH15","SH20"}),H5194="",I5194=""),E5194,"")
=IF(
AND(
OR( C5194="SHOT10", C5194="SHOT15", C5194="SHOT20", C5194="SH15", C5194="SH20" ),
H5194="",
I5194=""
),
E5194,
""
)

MIN array function non zeros only

I have been trying to get this array function to output (non-zero) minimum values in the 'FINAL DATA' AE column. Can you see a structural error in this formula?
=IF($C$4="All EMEA",
MIN(IF('FINAL DATA'!$2:$AE$250000<>0,
('FINAL DATA'!$J$2:$J$250000=$C$4)*('FINAL DATA'!$E$2:$E$250000=$E$4)*( 'FINAL DATA'!$AE$2:$AE$250000))),
MIN(IF('FINAL DATA'!$AE$2:$AE$250000<>0,
('FINAL DATA'!$K$2:$K$250000=$C$4)*('FINAL DATA'!$E$2:$E$250000=$E$4)*( 'FINAL DATA'!$AE$2:$AE$250000)))
)
By using <>0 that will eliminate zeroes and blanks, so that isn't the problem.....[although if you only want to eliminate blanks and have zero as a valid return value you should use <>""]
You can't multiply the conditions with the number range because by multiplying you get zeroes for any rows where the conditions are not satisfied, use multiple IFs instead, like this:
=MIN(IF('FINAL DATA'!$AE$2:$AE$250000<>0,IF('FINAL DATA'!$J$2:$J$250000=$C$4,IF('FINAL DATA'!$E$2:$E$250000=$E$4,'FINAL DATA'!$AE$2:$AE$250000))))
Second line, you have !$2, no column specified.
MIN(IF('FINAL DATA'!$2:$AE$250000<>0,
Also, it looks like you are trying to run a single If comparison against a range, which I don't think will work the way you are trying to use it.
Barry has identified the core problem (tests returnimg 0 to the MIN function).
Here's a refactor of your formula (still an array formula) that solves this, and is quite a bit shorter
=MIN(IF(($S:$S<>0)*($E:$E=$E$4)*(IF($C$4="All EMEA",$J:$J,$K:$K)=$C$4),
($S:$S)))
Note that this (as would your original formaul, when fixed) will return 0 if there are no qualifying values >0 in the ranges
You can eliminate the zeros by using an IF() function in an array formula. Consider the following:
A
Row -----
1 0
2 7
3 5
4 6
5
6 3
The array formula =MIN(IF($A$1:$A$6>0,$A$1:$A$6)) will return 3 because the 0 and blank cell are eliminated with the >0 portion of the if statement.

Resources