Getting "Too many functions" in Excel formula - excel

I am writing a formula for Excel. Excel says that I entered too many arguments. Am I missing any brackets or my formula is wrong?
10000+IF(AND(F5>=98%, (D17-D125)>0),((D5*2.5)+(0.2*(D17-D125))),(D5*2.5),IF(AND(98%>F5,F5>=90%,(D17-D125)>0),((D5*1.5)+(0.1*(D17-D125))),(D5*1.5),IF(AND(90%>F5,F5>=80%,(D17-D125)>0),((D5*0.5)+(0.05*(D17-D125))),(D5*0.5),IF(AND(F5<80%),(D17-D125)>0),((D5*0)+(0*(D17-D125))),(D5*0))))
Is there any shorter formula to use?

So, quick example to show how vlookup() works, Excel has good examples in the Function Reference. vlookup() can have all the arguments built-in so only one cell needed. Just shown it like this to show.
=VLOOKUP(A2,$A$7:$B$11,2,1)

I don't know what your intentions are mathematically, and it definitely seems like theres a simple solution here. But when analyzing your formula.. I had trouble almost instantly when breaking it up into a more procedural If/then/else structure.. So you do have misplaced parens, extra parameters to IF(), etc.
I really like the LET() function to setup variable names or simply to avoid repeating myself. And then since you're chaining IFs, just use IFS() instead..
LET() works like LET(name1, value1, name2, value2, result).
IFS() works like IFS(condition1, resultIf1, condition2, resultIf2)
Something like the following is at least easier on the eyes..
LET(
VarA, F5,
VarB, D17-D125,
VarC, D5,
VarD, VarB > 0,
IFS(
AND(VarA > 98%, VarD), D5*2.5,
AND(VarA < 98%, VarA >= 90%, VarD), D5*1.5 + 0.1*VarB,
AND(VarA < 90%, VarA >= 80%, VarD), D5*0.5 + 0.5*VarB,
...
TRUE, default value
)
)

Related

Excel formula to allow me to retrieve the codes of the most valuables drinks

Good night,
I'm trying to think of a simple excel formula to allow me to get the codes of the most valuables drinks.
I don't wanna use PivotTable for this one.
Ex:
I want to retrieve, for MALIBU, the code 8991
For JAMESON, the code 6113 etc
I'm stuck here since I woke up haha
Thanks!
Try below formula for dynamic spill result-
=LET(x,UNIQUE(C2:C12),y,BYROW(x,LAMBDA(r,INDEX(SORT(FILTER(A2:B12,C2:C12=r),2,-1),1,1))),HSTACK(x,y))
Using MAX function to consider the scenario where more than one code for a given drink can have the maximum value. In cell E2 use the following formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3), drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux,
TEXTJOIN(",",,FILTER(codes, (drinks = ux)
* (values = MAX(FILTER(values, drinks=ux))))))),
HSTACK(drinksUx, maxValues)
)
Here is the output:
Note: Another code for HEINEKEN was added for testing purpose of more than one code with maximum value.
XMATCH can be used for the same purpose too, but it is a more verbose formula:
=LET(rng, A2:C13, codes, INDEX(rng,,1), values, INDEX(rng,,2),
drinks, INDEX(rng,,3),drinksUx, UNIQUE(drinks),
maxValues, BYROW(drinksUx, LAMBDA(ux, TEXTJOIN(",",,
LET(maxValue, MAX(FILTER(values, drinks = ux)),
FILTER(codes, ISNUMBER(XMATCH(drinks & values, ux & maxValue))))))),
HSTACK(drinksUx, maxValues)
)

Excel - How can I shorten this formula

I wrote a formula which exceeds 8192 characters and I really need to reach the result of the formula. Actually it is repetetive calculation for different conditions. I'm sure when you see the formula you will get the idea. But there is short explanation below:
There are 10 different sources and regarding choosen source formula should work.
Regarding choosen currency I need to get result of related calculation.
Right now it is 10.290 chars.
Since this is my first question and I'm kinda new on Excel any help would be appreciated.
*Expected result need to be shown on "unit price" column and different for each item.
=IFERROR(IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="USD";core!$I29*core!$N$2+core!$I29*core!$N$2*core!$F29+core!$I29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3+core!$I29*core!$N$3*core!$F29+core!$I29*core!$N$3*core!$g29;"")));
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$I29/core!$N$2+core!$I29/core!$N$2*core!$F29+core!$I29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3/core!$N$2+core!$I29*core!$N$3/core!$N$2*core!$F29+core!$I29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";(core!$I29/core!$N$3+core!$I29/core!$N$3*core!$F29+core!$I29/core!$N$3*core!$g29);IF(core!$H29="USD";(core!$I29*core!$N$2/core!$N$3+core!$I29*core!$N$2/core!$N$3*core!$F29+core!$I29*core!$N$2/core!$N$3*core!$g29);IF(core!$H29="EURO";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;""))))))))))));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;IF(core!$H29="USD";core!$K29*core!$N$2+core!$K29*core!$N$2*core!$F29+core!$K29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$K29*core!$N$3+core!$K29*core!$N$3*core!$F29+core!$K29*core!$N$3*core!$g29;"")));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$K29/core!$N$2+core!$K29/core!$N$2*core!$F29+core!$K29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;IF(core!$H29="EURO";core!$K29*core!$N$3/core!$N$2+core!$K29*core!$N$3/core!$N$2*core!$F29+core!$K29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=2;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$K29/core!$N$3+core!$K29/core!$N$3*core!$F29+core!$K29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$K29*core!$N$2/core!$N$3+core!$K29*core!$N$2/core!$N$3*core!$F$29+core!$K29*core!$N$2/core!$N$3*core!$g$29;IF(core!$H29="EURO";core!$K29+core!$K29*core!$F29+core!$K29*core!$g29;"")))))))))));
IF(core!$D$11=3;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;IF(core!$H29="USD";core!$M29*core!$N$2+core!$M29*core!$N$2*core!$F29+core!$M29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$M29*core!$N$3+core!$M29*core!$N$3*core!$F29+core!$M29*core!$N$3*core!$g29;"")));
IF(core!$D$11=3;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$M29/core!$N$2+core!$M29/core!$N$2*core!$F29+core!$M29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;IF(core!$H29="EURO";core!$M29*core!$N$3/core!$N$2+core!$M29*core!$N$3/core!$N$2*core!$F29+core!$M29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=3;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$M29/core!$N$3+core!$M29/core!$N$3*core!$F29+core!$M29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$M29*core!$N$2/core!$N$3+core!$M29*core!$N$2/core!$N$3*core!$F29+core!$M29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$M29+core!$M29*core!$F29+core!$M29*core!$g29;"")))))))))));
IF(core!$D$11=4;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;IF(core!$H29="USD";core!$O29*core!$N$2+core!$O29*core!$N$2*core!$F29+core!$O29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$O29*core!$N$3+core!$O29*core!$N$3*core!$F29+core!$O29*core!$N$3*core!$g29;"")));
IF(core!$D$11=4;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$O29/core!$N$2+core!$O29/core!$N$2*core!$F29+core!$O29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;IF(core!$H29="EURO";core!$O29*core!$N$3/core!$N$2+core!$O29*core!$N$3/core!$N$2*core!$F29+core!$O29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=4;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$O29/core!$N$3+core!$O29/core!$N$3*core!$F29+core!$O29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$O29*core!$N$2/core!$N$3+core!$O29*core!$N$2/core!$N$3*core!$F29+core!$O29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$O29+core!$O29*core!$F29+core!$O29*core!$g29;"")))))))))));
IF(core!$D$11=5;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;IF(core!$H29="USD";core!$Q29*core!$N$2+core!$Q29*core!$N$2*core!$F29+core!$Q29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$Q29*core!$N$3+core!$Q29*core!$N$3*core!$F29+core!$Q29*core!$N$3*core!$g29;"")));
IF(core!$D$11=5;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$Q29/core!$N$2+core!$Q29/core!$N$2*core!$F29+core!$Q29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;IF(core!$H29="EURO";core!$Q29*core!$N$3/core!$N$2+core!$Q29*core!$N$3/core!$N$2*core!$F29+core!$Q29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=5;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$Q29/core!$N$3+core!$Q29/core!$N$3*core!$F29+core!$Q29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$Q29*core!$N$2/core!$N$3+core!$Q29*core!$N$2/core!$N$3*core!$F29+core!$Q29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$Q29+core!$Q29*core!$F29+core!$Q29*core!$g29;"")))))))))));
IF(core!$D$11=6;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;IF(core!$H29="USD";core!$S29*core!$N$2+core!$S29*core!$N$2*core!$F29+core!$S29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$S29*core!$N$3+core!$S29*core!$N$3*core!$F29+core!$S29*core!$N$3*core!$g29;"")));
IF(core!$D$11=6;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$S29/core!$N$2+core!$S29/core!$N$2*core!$F29+core!$S29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;IF(core!$H29="EURO";core!$S29*core!$N$3/core!$N$2+core!$S29*core!$N$3/core!$N$2*core!$F29+core!$S29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=6;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$S29/core!$N$3+core!$S29/core!$N$3*core!$F29+core!$S29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$S29*core!$N$2/core!$N$3+core!$S29*core!$N$2/core!$N$3*core!$F29+core!$S29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$S29+core!$S29*core!$F29+core!$S29*core!$g29;"")))))))))));
IF(core!$D$11=7;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;IF(core!$H29="USD";core!$U29*core!$N$2+core!$U29*core!$N$2*core!$F29+core!$U29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$U29*core!$N$3+core!$U29*core!$N$3*core!$F29+core!$U29*core!$N$3*core!$g29;"")));
IF(core!$D$11=7;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$U29/core!$N$2+core!$U29/core!$N$2*core!$F29+core!$U29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;IF(core!$H29="EURO";core!$U29*core!$N$3/core!$N$2+core!$U29*core!$N$3/core!$N$2*core!$F29+core!$U29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=7;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$U29/core!$N$3+core!$U29/core!$N$3*core!$F29+core!$U29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$U29*core!$N$2/core!$N$3+core!$U29*core!$N$2/core!$N$3*core!$F29+core!$U29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$U29+core!$U29*core!$F29+core!$U29*core!$g29;"")))))))))));
IF(core!$D$11=8;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$W29+core!$W29*core!$F29++core!$W29*core!$g29;IF(core!$H29="USD";core!$W29*core!$N$2+core!$W29*core!$N$2*core!$F29+core!$W29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$W29*core!$N$3+core!$W29*core!$N$3*core!$F29+core!$W29*core!$N$3*core!$g29;"")));
IF(core!$D$11=8;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$W29/core!$N$2+core!$W29/core!$N$2*core!$F29+core!$W29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$W29+core!$W29*core!$F29+core!$W29*core!$g29;IF(core!$H29="EURO";core!$W29*core!$N$3/core!$N$2+core!$W29*core!$N$3/core!$N$2*core!$F29+core!$W29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=8;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$W29/core!$N$3+core!$W29/core!$N$3*core!$F29+core!$W29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$W29*core!$N$2/core!$N$3+core!$W29*core!$N$2/core!$N$3*core!$F29+core!$W29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$W29+core!$W29*core!$F29+core!$W29*core!$g29;"")))))))))));
IF(core!$D$11=9;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;IF(core!$H29="USD";core!$Y29*core!$N$2+core!$Y29*core!$N$2*core!$F29+core!$Y29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$Y29*core!$N$3+core!$Y29*core!$N$3*core!$F29+core!$Y29*core!$N$3*core!$g29;"")));
IF(core!$D$11=9;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$Y29/core!$N$2+core!$Y29/core!$N$2*core!$F29+core!$Y29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;IF(core!$H29="EURO";core!$Y29*core!$N$3/core!$N$2+core!$Y29*core!$N$3/core!$N$2*core!$F29+core!$Y29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=9;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$Y29/core!$N$3+core!$Y29/core!$N$3*core!$F29+core!$Y29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$Y29*core!$N$2/core!$N$3+core!$Y29*core!$N$2/core!$N$3*core!$F29+core!$Y29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$Y29+core!$Y29*core!$F29+core!$Y29*core!$g29;"")))))))))));
IF(core!$D$11=10;IF($F15>0;
IF(core!$D$7="TL";IF(core!$H29="TL";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;IF(core!$H29="USD";core!$AA29*core!$N$2+core!$AA29*core!$N$2*core!$F29+core!$AA29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$AA29*core!$N$3+core!$AA29*core!$N$3*core!$F29+core!$AA29*core!$N$3*core!$g29;"")));
IF(core!$D$11=10;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$AA29/core!$N$2+core!$AA29/core!$N$2*core!$F29+core!$AA29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;IF(core!$H29="EURO";core!$AA29*core!$N$3/core!$N$2+core!$AA29*core!$N$3/core!$N$2*core!$F29+core!$AA29*core!$N$3/core!$N$2*core!$g29;"")));
IF(core!$D$11=10;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";core!$AA29/core!$N$3+core!$AA29/core!$N$3*core!$F29+core!$AA29/core!$N$3*core!$g29;IF(core!$H29="USD";core!$AA29*core!$N$2/core!$N$3+core!$AA29*core!$N$2/core!$N$3*core!$F29+core!$AA29*core!$N$2/core!$N$3*core!$g29;IF(core!$H29="EURO";core!$AA29+core!$AA29*core!$F29+core!$AA29*core!$g29;""))))))))))))))))))))
*(core!$G29+1))
enter image description here
The IFERROR has the format IFERROR(Value, Value_if_error). Your Value is this:
IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="TL";IF(core!$H29="TL";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="USD";core!$I29*core!$N$2+core!$I29*core!$N$2*core!$F29+core!$I29*core!$N$2*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3+core!$I29*core!$N$3*core!$F29+core!$I29*core!$N$3*core!$g29;"")));IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="USD";IF(core!$H29="TL";core!$I29/core!$N$2+core!$I29/core!$N$2*core!$F29+core!$I29/core!$N$2*core!$g29;IF(core!$H29="USD";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;IF(core!$H29="EURO";core!$I29*core!$N$3/core!$N$2+core!$I29*core!$N$3/core!$N$2*core!$F29+core!$I29*core!$N$3/core!$N$2*core!$g29;"")));IF(core!$D$11=1;IF($F15>0;IF(core!$D$7="EURO";IF(core!$H29="TL";(core!$I29/core!$N$3+core!$I29/core!$N$3*core!$F29+core!$I29/core!$N$3*core!$g29);IF(core!$H29="USD";(core!$I29*core!$N$2/core!$N$3+core!$I29*core!$N$2/core!$N$3*core!$F29+core!$I29*core!$N$2/core!$N$3*core!$g29);IF(core!$H29="EURO";core!$I29+core!$I29*core!$F29+core!$I29*core!$g29;""))))))))))));
Taking your formula, splitting out the first part of the IFERROR, and eliminating the spurious code (i.e. IF(A=1, IF(B=2, IF(A=1, ALWAYS_TRUE, ALWAYS_FALSE), C), D) is functionally identical to IF(A=1, IF(B=2, ALWAYS_TRUE, C), D)), I then built the following table:
The Red, Blue and Green text are Common Terms, present in every formula.
Examining this, and rearranging it slightly, I spot the following patterns:
When D7 is "USD", Divide by $N$2
When D7 is "EURO", Divide by $N$3
When H29 is "USD", Multiply by $N$2
When H29 is "EURO", Multiply by $N$3
Implicitly, the following rules also exist:
When D7 is "TL", Divide by 1
When H29 is "TL", Multiply by 1
I can use a VLOOKUP to pick which cells to use, resulting in the form VLOOKUP(H29,..) * (Common_Terms) / VLOOKUP(D7,..)
This allows me to rewrite your Value as follows:
IF(AND(core!$D$11=1,$F15>0), IF(AND(MATCH(core!$D$11,{"TL","USD","EURO","*"},0)<4, MATCH(core!$H$29,{"TL","USD","EURO","*"},0)<4), VLOOKUP(core!H$29,{"USD",core!$N$2;"Euro",core!$N$3;"TL",1},2,FALSE)*(core!$I29 + core!$I29*core!$F29 + core!$I29*core!$g29)/VLOOKUP(core!H$29,{"USD",core!$N$2;"Euro",core!$N$3;"TL",1},2,FALSE), ""), FALSE)
Which is a third of the length. You should be able to manage similar optimisation of almost every IF condition you have.
More importantly, a lot of your repeated (and unnecessary) IF conditions are checking if H29 and D7 are "TL"/"USD"/"EUR", or checking that F15>0. You can eliminate these by making your outermost IF statement look like this:
=IF(AND($F15>0, MATCH(core!$D$7, core!$D$11, {"TL","USD","EURO","*"},0)<4, MATCH(core!$H$29, {"TL","USD","EURO","*"},0)<4), ALL_THREE_CONTITIONS_ARE_TRUE, "")

Nesting 6 IF statements in excel 2017 and get the #NAME? error

Im trying to nest 6 IF statements in my excel spread sheet but I get the error #NAME? which I know is most likely a syntax error.
However I cant find the syntax error. I read online that you can nest up to 7 IF statements, does this not apply to Excel 2017?
Heres my function:
=IF(AND(F2=KWILA, B14=0.14), B38, IF(AND(F2=KWILA, B14=0.9), C38, IF(AND(F2=VITEX, B14=0.9), C39, IF(AND(F2=PINE, B14=0.14), B40, IF(AND(F2=PINE, B14=0.9), C40, IF(AND(F2=MACRO, B14=0.14), B41, H2))))))
Can someone help me please?
When combining functions in a formula, start simple, with a single function. Get it working and producing the result you want before making it more complex by adding a second function (or five more).
Since your question doesn't include an example of the data you're working with, I can't be sure of the issue, but I suspect you're trying to compare the text (strings) like KWILA to the cells (like A2).
If so, the problem is that text (strings) needs to be enclosed in "Quotation Marks".
Almost every time I more than 2 nested IF's, there's usually a more efficient way to accomplish the same thing.
In this cas, I split up the formula in Notepad to see what the goal is:
=IF(
AND(F2=KWILA, B14=0.14), B38
AND(F2=KWILA, B14=0.9), C38,
AND(F2=VITEX, B14=0.9), C39,
AND(F2=PINE, B14=0.14), B40,
AND(F2=PINE, B14=0.9), C40,
AND(F2=MACRO, B14=0.14), B41,
...if none of the above: H2
I encourage you to double check your criteria above - since, at first glance, it looks like a "broken pattern". For example there are two 38's, one 39, two 40's and one 41.
Assuming it's correct, I look for anything I can group, and I see that there are only 2 options for B14. So I regroup:
=IF(B14=0.14,
IF( F2=KWILA, B38
F2=PINE, B40,
F2=MACRO, B41,
IF(B14=0.9,
IF( F2=KWILA, C38,
F2=VITEX, C39,
F2=PINE, C40,
...if none of the above: H2
I also noticed that there are only 4 options for F2, so I considered using CHOOSE instead of IF but I'm not sure how B14 relates the the rest of the data (since it wasn't posted) so we'll stick with this simplification for now.
Midway through putting it "back together" I have:
=IF(B14=0.14,
IF( F2=KWILA, B38, if( F2=PINE, B40, if( F2=MACRO, B41, h2 ))),
IF(B14=0.9,
IF( F2=KWILA, C38, if( F2=VITEX, C39, if( F2=PINE, C40, h2 )))
h2 )
basically 2 set of IF statements. Note that I used H2 three times for "else confitions" -I'm not happy with this and I can almost guarantee there's a better way, but again, without seeing your data.....
Put back into a formula, we get a slightly more manageable:
=IF(B14=0.14,IF(F2="KWILA",B38,IF(F2="PINE",B40,IF(F2="MACRO",B41,H2))),
IF(B14=0.9,IF(F2="KWILA",C38,IF(F2="VITEX",C39,IF(F2="PINE",C40,H2))),H2))
I can't guarantee this will work since I wasn't able to test it, since... no data included in the question. You don't need to switch to this if your method works after adding the quotes.
There are still other alternate way this could have been simplified (and easier to understand or change later) which I won't get into now. Personally, I would have put the values in a table on another worksheet, and used INXDEX/MATCH to get the values I needed.
-

Excel Nested IF AND

I have the following formula:
=IF(AND(A1=0,A3="","1 item"),
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items"))))
3 combinations of cell values in A1 and A3 return text which I'm calling "1 item"
Only 1 combination of cells value returns text which I'm calling "2 items".
The only combination to return "2 items" is where A1=1 AND A3="".
The formatting is wrong but I'm not sure where.
Any help would be greatly appreciated.
this is the correct formula -
brackets of AND() were not properly closed.
=IF(AND(A1=0,A3=""),"1 item",IF(AND(A1=0,A3="Exclude"),"1 item",IF(AND(A1=1,A3="Exclude"),"1 item","2 items")))
Excel's IF expects three parameters: Condition, What to do if condition is TRUE, and what to do if condition is FALSE.
I'll re-format your formula so you can see where the error is:
IF( AND(A1=0,A3="","1 item") ,
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items")
)
)
)
As you can see
For the first IF you are not providing what to do if condition is FALSE,
The same for the second IF,
The third IF has no definition of what to do if the condition is TRUE or FALSE.
Hope this helps you.
UPDATE
Following your comment (which is still not clear to me), hereinafter I'm providing simple rules you may use to construct your formula correctly:
Write your formula as a piece of text (like the example I show above) so that you can easily read, edit and verify it,
Remember that Excel's IF has three parameters: Condition, result when condition is TRUE and result when condition is FALSE,
Within any of these three parameters, you can include whatever you want PROVIDED that the result is compliant with what the function expects for that parameter; for instance, writing for the first parameter 3=8 is completely legal since the result is FALSE (while 4=2*2 would yield TRUE).
Having this in mind, here is the formula I think you are looking for (WARNING!!! I'm not sure I understood what you need, but if not, changing it should be very easy for you now):
IF(AND(A1=1,A3=""),"2 items","1 item")
This is based on your wording: The only combination to return "2 items" is where A1=1 AND A3="".

Excel nested IF with "AND" operator behaving weird

I having a weird situation in Excel spreadsheet. I'm applying a simple nested IF statement as below:
= IF( AND(A1-INT(A1)>=0.3,A1-INT(A1)<=0.7),INT(A1)+0.5,
IF( AND(A1-INT(A1)>=0,A1-INT(A1)<=0.2),INT(A1),
IF( AND(A1-INT(A1)>=0.8,A1-INT(A1)<=0.9),INT(A1)+1, "NON-CHECKED" )
)
)
Suppose if "A1" contains a value 32.9, the result should be 33. It works fine until the value of "63.9". As soon as A1 contains value of "64.9", it does not check the last condition and prints out "NON-CHECKED".
It's a strange thing that it works fine until a value of 63.9 and after that it starts become FALSE.
I tried the same formula in Office Suit and Google Docs too.
Am I missing something here ?
You can test the formula here:
Sample Spreadsheet
Thanks.
Please try replacing A1-INT(A1) with ROUND(MOD(A1,1),10). This seems to work for numbers less then 10^9. If you work with higher numbers, you should decrease precision.
Aren't you just rounding to the nearest 0.5? MROUND function does that
=MROUND(A1,0.5)

Resources