AND statement failing inside IF statement but works when used separately - excel-formula

I have the below formula that does not work:
=IFERROR(INDEX(data[Ticket No.], SMALL(IF(AND(data[SLA (Hrs)]>=-24,data[SLA (Hrs)]<0), ROW(data[SLA (Hrs)])-ROW(Data!$D$2)+1), ROW(1:1))),"No Match")
When I remove the AND and just use either of the criteria, the formula works:
=IFERROR(INDEX(data[Ticket No.], SMALL(IF(data[SLA (Hrs)]>=-24, ROW(data[SLA (Hrs)])-ROW(Data!$D$2)+1), ROW(1:1))),"No Match")
=IFERROR(INDEX(data[Ticket No.], SMALL(IF(data[SLA (Hrs)]<0, ROW(data[SLA (Hrs)])-ROW(Data!$D$2)+1), ROW(1:1))),"No Match")
When I test the AND statement on it's own, it returns TRUE.
AND(data[SLA (Hrs)]>=-24,data[SLA (Hrs)]<0)
The full formula outputs:
It returns 1 'Ticket No.' with 'SLA (Hrs)' of -2000 which is incorrect.
I have 10 'Ticket No.' with 'SLA (Hrs)' between -24 and 0 in the 'data' table.
Any insight anyone can offer would be greatly appreciated.
Kind Regards,
Alex

Array formulas do not work with AND() or OR() Use * or + respectively.
AND(data[SLA (Hrs)]>=-24,data[SLA (Hrs)]<0)
Should be:
(data[SLA (Hrs)]>=-24)*(data[SLA (Hrs)]<0)
so:
=IFERROR(INDEX(data[Ticket No.], SMALL(IF((data[SLA (Hrs)]>=-24)*(data[SLA (Hrs)]<0), ROW(data[SLA (Hrs)])-ROW(Data!$D$2)+1), ROW(1:1))),"No Match")
remember to Confirm with Ctrl-Shift-Enter instead of Enter when exiting Edit mode.

Related

Getting "Too many functions" in Excel formula

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
)
)

OR condition in a formula

The below formula helps to Start from ASD and before the slash it prints all the data.
Query:
Now as per the requirement, i need to search for two words with OR condition.
For eg it should either start with ASD or DEF I tried with OR condition but that is not working.
Can someone pls guide in this.
Working Formula:
=IF(ISNUMBER(SEARCH("ASD",A11)),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
With OR Condition(which is not working)
=IF(ISNUMBER(SEARCH("ASD",A11) OR SEARCH("DEF",A11)),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
It has to look like:
=IF(OR(ISNUMBER(SEARCH("ASD",A11)), ISNUMBER(SEARCH("DEF",A11))),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")
It seems that the order of the operations in your formula is the issue.
Example:
OR – =IF(OR(Something is True, Something else is True), Value if True, Value if False)
cf: https://support.microsoft.com/en-us/office/using-if-with-and-or-and-not-functions-d895f58c-b36c-419e-b1f2-5c193a236d97
My best guess is that your formula should be
=IF(OR(ISNUMBER(SEARCH("ASD",A11), SEARCH("DEF",A11))),MID(A11,SEARCH("""",A11)+1,SEARCH("/",A11)-1-SEARCH("""",A11)),"")

Why the INDIRECT excel method doesn't work as expected

These two methods bring to a different result. Why?
=OR(NOT(ISERROR(SEARCH('[FILTER_OBJECT_SETTING.xlsx]Filter Object'!$A$1:$A$5);A1))))
Correct value!! I get TRUE! It works!
=OR(NOT(ISERROR(SEARCH('[FILTER_OBJECT_SETTING.xlsx]Filter Object'!$A$1:INDIRECT("$A$5");A1))))
Uncorrect value!! I get FALSE! It doesn't work as expected!!
In A1 there is the following value:
0,"Annotations","10:00:00:00","10:00:08:23","Testo"
Instead, in "FILTER_OBJECT_SETTING.xlsx" there are the following values from A1 to A5:
"Abbigliamento"
"Vestito"
"Porta"
"Testo"
"Statua"
Use INDEX/MATCH to return the last cell:
=OR(ISNUMBER(SEARCH('[FILTER_OBJECT_SETTING.xlsx]Filter Object'!$A$1:INDEX('[FILTER_OBJECT_SETTING.xlsx]Filter Object'!$A:$A;MATCH("zzz";'[FILTER_OBJECT_SETTING.xlsx]Filter Object'!$A:$A));A1)))

Having trouble in nested IFs in excel with true or false values in each IF statement

=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):

IF statement with three conditions

column V is homework actual finish date
column W is required finish date
condition 1: if V is not blank, return value "ok"
condition 2: if "V is blank" and "W is blank", return value "ok"
condition 3: if "V is blank" and "W>=today()", return value "overdue"
I'm only able to combine condition 1 and 3 in my IF formula:
=IF(NOT(ISBLANK(V2)),"ok",IF(W2<=TODAY(),"over due","ok"))
Could anybody help me add condition two into my formula?
thanks for everybody's help/ im really new to stackoverflow.
and i have already learned something from everybody.
btw i made a typo in my condition 3, it should be "W<=today()" instead "W>=today()"
thanks
=if( and( not(isblank(v2)), not(isblank(w2)) ), "ok",
if( not(isblank(v2)), "ok",
if( and( isblank(v2), w2 >= today() ), "overdue", "ok" )
)
)
Paste this directly into the formula box and see how it works.
Let me see;
Your decision tree is missing one possible output; when V is blank, W !is blank and W<=today()
once you tell us what output means to you, we can easily help you.
Try this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2), "ok",IF(AND(ISBLANK(V2),W2 >= TODAY()),"Over Due", "Error")))
As tip for future macros, try building them up a little at a time. For IF statements it can get tricky but this may help.
Write the first condition like this with 'Other Value' as a place holder.
=IF(NOT(ISBLANK(V2)),"ok","Other Value")
Once you have that bit working the way you like it then put in the false condition like this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2),"ok","Other Value"))
And then finally add your last condition.
This is quite simple with one AND statement. First, redefine the logic you need for yourself: there are only two outcomes you care about: an assignment is unfinished and overdue, OR an assignment is finished/not yet due. So to write our IF statement, check only whether the assignment is unifinished and overdue. In any other case, the status will be the same.
Edit per comment
=IF(AND(ISBLANK(V1),W1<=TODAY(),W1>1),"overdue","ok")

Resources