I have Excel sheet with value and another column value that depend of theme
If value >48 the value will be 8 if <=40 value will be 0 if value inferior a 48 and supperieru a 40 value will be column -40 I tried this but didn't work
=SI(AH15>48,8,SI(ET(AH15>40,AH15<48,AH15-40))
Or english:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<48,AH15-40))
You are throwing in an AND function to check multiple conditions in a wrong manner:
All these conditions ET(AH15>40,AH15<48,AH15-40) can never be true since the last parameter is a calculation. Either way, what you tried to do is maybe:
=SI(AH15<=40,0,SI(AH15>48,8,AH15-40))
Which translates to:
=IF(AH15<=40,0,IF(AH15>48,8,AH15-40))
Try this one:
=IF(AH15>48,8,IF(AND(AH15>40,AH15<=48),AH15-40,0))
Hope it helps
Related
I am using a formula based on SUMPRODUCT, SUBTOTAL, and OFFSET. To enable count of visible rows only with criteria. I a trying it on a simple sample data which as follows. Data starts from B4 in the Range B4:B12 Header B3:
B Column
HD
2
2
4
6
2
1
8
9
2
Formula is :
=SUMPRODUCT((B4:B12=B4)*(SUBTOTAL(103,OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0))))
It gives correct result of 4 counts for a value of 2.
I went for evaluation of the formula to fully understand its logic. I could comprehend major part of its logic but certain steps are not quite clear to me. I am reproducing evaluation steps below with my comments.
Step -1
=SUMPRODUCT(({2;2;4;6;2;1;8;9;2}=2)*(SUBTOTAL(103,OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0))))
OK
Step -2
=SUMPRODUCT(({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE})*(SUBTOTAL(103,OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0))))
OK
STEP-3
=SUMPRODUCT(({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE})*(SUBTOTAL(103,OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0))))
OK
STEP-4
=SUMPRODUCT(({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE})*(SUBTOTAL(103,OFFSET($B$4,{4;5;6;7;8;9;10;11;12}-MIN({4;5;6;7;8;9;10;11;12}),0))))
OK
STEP-5
=SUMPRODUCT(({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE})*(SUBTOTAL(103,OFFSET($B$4,{4;5;6;7;8;9;10;11;12}-4),0))))
OK
STEP-6
=SUMPRODUCT({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}*(SUBTOTAL(103,OFFSET($B$4,{0;1;2;3;4;5;6;7;8},0))))
Why {0;1;2;3;4;5;6;7;8} ??
STEP-7
=SUMPRODUCT({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}*(SUBTOTAL(103,{#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;})))
Why {#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;} ??
STEP-8
=SUMPRODUCT({TRUE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}*({1;1;1;1;1;1;1;1;1}))
How 1 instead of #VALUE!
STEP-9
=SUMPRODUCT({1;1;0;0;1;0;0;0;1})
OK
Step -10
4
OK
I am not having full clarity on the following points
STEP-6 : Why {0;1;2;3;4;5;6;7;8}
STEP-7: Why {#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;}
STEP-8: How 1 instead of #VALUE!
Hope Someone helps in clarifying the logic behind these mentioned spots. Please forgive me for asking clarity on such a trivial matter.
STEP-6 : Why {0;1;2;3;4;5;6;7;8}
Because the {4;5;6;7;8;9;10;11;12}-4 evaluates to {4-4;5-4;6-4;7-4;8-4;9-4;10-4;11-4;12-4} which is {0;1;2;3;4;5;6;7;8}
STEP-7: Why {#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!}
The formula evaluator fails getting the values out of the 9 cell references got via OFFSET($B$4,{0;1;2;3;4;5;6;7;8},0) = {$B$4;$B$5;$B$6;$B$7;$B$8;$B$9;$B$10;$B$11;$B$12} in array context. But that does not matter because:
STEP-8: How 1 instead of #VALUE!
the SUBTOTAL(103,... is a COUNTA subtotal which, for each single cell reference of the 9 cell references got in step 7, counts 1 if it is not hidden, else 0. So it does not matter whether the cell values was evaluated or not.
Btw.: The same can be achieved using
=SUMPRODUCT((B4:B12=B4)*(SUBTOTAL(103,INDIRECT("B"&ROW(B4:B12)))))
Annotation:
Such formulas are result of trial and error. I doubt any Excel programmer was able predicting all usages of the functions they implemented. There are usages of Excel functions in the wild which are as much thought outside the box that they originally could not have thought so.
Bonus:
=SUMPRODUCT(OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0))
results in 0 using your values in B4:B12.
Here the formula evaluator also fails getting the values out of the 9 cell references got via OFFSET($B$4,{0;1;2;3;4;5;6;7;8},0) = {$B$4;$B$5;$B$6;$B$7;$B$8;$B$9;$B$10;$B$11;$B$12} in array context. And the result is {#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!;#VALUE!}. But now it matters because we need the values.
In that case we can use N function to force getting the values
=SUMPRODUCT(N(OFFSET(B4,ROW(B4:B12)-MIN(ROW(B4:B12)),0)))
This results in 36, the sum of your values in B4:B12.
=IF(AND(A2<=20151231),(B2=0) 0, 15, IF(AND(A2>=20190101,B2>=2),15, 7.5))
This is what I entered in the function.
if A2 is less than 20151231 and B2 is equal to 0 the value will be 0.
if A2 is greater than 20190101 and B2 is equal to or greater than 2 the value will be 15.
the problem is that excel says that I entered too many arguments and when I try to derive it it says that there is something wrong with the function I entered.
Try this:
=IF(AND(A2<=20151231,B2=0),"0",IF(AND(A2>=20191010,B2>=2),15,""))
it seems your formula has too much close and open parenthesis. When using "and()" enclose all logic in one set of parenthesis.
Hope this helps. Thanks
Reymond's answer is correct, assuming that you want the result to be:
0 - if A2<=20151231 AND B2=0
15 - if A2>=20190101 AND B2>=2
7.5 - if neither of these cases are true.
If you are struggling to see what parameters you are passing to which function, I would suggest that you format your formulas so that they are easier to read:
=IF(
AND(A2<=20151231, B2=0),
0,
IF(
AND(A2>=20190101,B2>=2),
15,
7.5
)
)
This makes it much easier to see what is going on and it can even be done in the excel formula bar if you wish (by using Alt+Enter):
I have this IF statement:
=IF(AG3<=7,"1",IF(15<=AG3<=21,"2",IF(22<=AG3<=28,"3",IF(29<=AG3<=35,"4",IF(36<=AG3<=42,"5",IF(43<=AG3<=49,"6",IF(50<=AG3<=56,"7")))))))
but either it gives me a 1 or "FALSE"
All the values are within the ranges and should be showing various numbers
Excel does not use 50<=AG3<=56. The way Excel will read this is it will resolve AG3<=56 which will resolve to TRUE or FALSE which have the values of 1 and 0 respectively. And since 50 is greater than both those it will always return FALSE and since you did not specify a final false argument Excel returns FALSE
It needs to be AND(50<=AG3, AG3<=56)
Also "1" returns a number as text and not a true number, remove the quotes.
So:
=IF(AG3<=7,1,IF(AND(15<=AG3,AG3<=21),2,IF(AND(22<=AG3,AG3<=28),3,IF(AND(29<=AG3,AG3<=35),4,IF(AND(36<=AG3,AG3<=42),5,IF(AND(43<=AG3,AG3<=49),6,IF(AND(50<=AG3,AG3<=56),7,"Value not in specs")))))))
But based on your criteria you could use:
=IF(OR(AND(AG3>=8,AG3<=14),AG3>56),"Not to Spec",MATCH(AG3,{-1E+99,15,22,29,36,43,40}))
Don't use Nested IFs if you can avoid it. Instead, use a banded VLOOKUP: it's many times more efficient, and a heck of a lot simpler to troubleshoot. Something like the answer here:
Excel IF statement Not returning the appropriate Value
In your case, here's your lookup list:
Note that since you haven't specified what should happen between 8 and 14 or over 57 I have simply put =NA() in those bands.
And here's the result for a range of numbers:
...and here's the formula that was used in the second column of that second table (using table notation):
=VLOOKUP([#Value],Table3,2,TRUE)
I'm trying to do some transformation with numbers in excel. First i have that table:
And as you can see, i have Random Digits, which is generated by using RANDBETWEEN. Now i want the Column Type, to be automatically Generated. So for example if Random Digits is:
From 1 - 35 = Good
36 - 80 = Fair
81 - 100 = Poor
I was already trying with IF function, but with if function i'm able to generate only 2 values and not 3.
Thank you for answers.
INDEX and MATCH are a good way to avoid nesting lots of IF statements (generally to be avoided!):
=INDEX({"Good","Fair","Poor"},MATCH(B2,{0,36,81},1))
If you really wanted to use an IF statement, it would look like this:
=IF(B2<36,"Good",IF(B2<81,"Fair","Poor"))
Nest the If so where you get the true value just output what you need but if its false then just write another if statement...
Use one IF inside another IF like this:
=if('From 1 - 35';'thing to do if is true';if('36 - 80';'thing to do if is true';'thing to do when is 81 - 100'))
The excel formula you are looking for is
=IF(B1>100,"error",IF(B1>=81,"Poor",IF(B1>=36,"Fair",IF(B1>=1,"Good","error"))))
This will display the word "error" if you range is >100 or <1. Other answers have failed to address the cases where the number is >100 or <1, as the question specifically bounds the set of responses to be between 1 and 100.
The formula works as a nested if statement. In pseudo code the formula is equivalent to:
if(B1>100)
then "Error"
Else if (B1>=81)
then "Poor"
Else if (B1>=36)
then "Fair"
Else if (B1>=1)
then "Good"
else
"Error"
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.