Excel Nested IF statements returning False - excel

I am constructing a nested IF statement, and I believe I am missing an ELSE but I cannot figure out where. I have the following statement:
=
IF(AND(B2="4",E2="R37",X2="Y"), "Non-Competing",
IF(AND(B2="4",E2="R37",X2="N"), "Competing",
IF(AND(B2="4",E2<>"R37",RIGHT(Z2,2)="00"), "Non-Competing",
IF(AND(B2="4",E2<>"R37",RIGHT(Z2,2)<>"00"), "Competing",
IF(B2<>"4","-")))))
I thought the last bit would cover the rest, but I am receiving a FALSE when I was hoping to get a result. For example, when B2=4, E2=R37, and X2=Y, I am expecting "Non-Competing" but am receiving FALSE. I also tried a combination with OR:
IF(OR(AND(B41="4",E41="R37",X41="Y"),
AND(B41="4",E41<>"R37",RIGHT(Z41,2)="00")), "Non-Competing",
IF(OR(AND(B41="4",E41="R37",X41="N"), AND(B41="4",E41<>"R37",RIGHT(Z41,2)
<>"00")), "Competing",
IF(B41<>"4","-")))
...which gives me the same result.
Any assistance would be greatly appreciated!

The missing else is in IF(B2<>"4","-"). You need IF(B2<>"4","-",<whatever last-ditch-answer>) If you are reaching False, then B2 is 4, but none of the other full conditions were met.
Without seeing your data, I can't know for sure, but I'm guessing that you may have intended that entire statement to behave as an else. If that is case, I would replace IF(B2<>"4","-") directly with "-".

Related

IfError with else, does this function exist in Excel?

While trying to help the author of this other question, I bumped (again) into the situation that I would like the following Excel function:
=IFERROR(value, value_if_error, value_if_no_error)
In other words, I'm looking for an IFERROR() function with an else-clause.
The issue is: it can in theory be done as follows:
=IF(IFERROR(function(),error_value),value_if_error,value_if_no_error)
But what if error_value is a possible outcome of function()? That would make it impossible to use IFERROR(): e.g. function() returns a string, which can be anything, also an empty string, but it might also generate an error.
Edit: some clarification
Let me give an example:
=IFERROR(B3, "weird")
In "B3", there is a function, which returns a string, but even in case the value of this string is "weird", this is ok. How can I distinguish the erroneous case and the case where "weird" is a normal correct result?
As an image says more than a thousand words:
Next to IFERROR(), there also is the ISERROR() function, which can be used as an input for an IF()-clause:
=IF(ISERROR(value),value_if_error,value_if_no_error)

Why doesn't my excel vba if/or statement work correctly?

I'm comparing values of numbers from 2 data sheets, and I've dropped the relevant data from both into their own arrays. I need to find matching values to run other steps of analysis.
For i = Lbound(Array1) to UBound(Array1)
For j = LBound(Array2) to UBound(Array2)
If (criteria for Array2) then
variable = 11111
Else
variable = 22222
End if
If variable = Array1(i,1) Or variable = Array1(i,2) or variable = Array1(i,3) then
more steps
Else
more steps
End if
next j
next i
The first if statement sets the variable correctly, but the variable doesn't match any of the criteria. It doesn't go to the else like it should. Now I only know this because I walked through the code step by step. If I just F5 and run the thing, "Excel is not responding". I don't know what the hang up it. All of my variables are declared and assigned a type, I'm not missing any closing statements. And I have no idea what I'm doing wrong.
What do I need to check for in my code?
EDIT
Sorry, but in this instance I'm not allowed to upload any code here. It's work related, NDA kind of stuff. Hence the pseudo code. What I need to show wouldn't be a big deal(at least I don't think it would), but I'm not risking it.
My apologies.
The solution, as it turns out, has to do with a poorly named array(not me) and a simple typo(definitely me). I'm certain that would have been an easy solve for the good citizens of Stack Overflow if I would have been allowed to post actual code.
For what's it worth, I think it's dumb that I couldn't in this case. Thanks #ScottCraner and #SuperSymmertry for trying to be helpful even without much to go on.
Super, I'm still curious about Val. If you've got a minute, I would appreciate more knowledge on that. Anything from an actual person is better than Microsoft documentation.

Excel: Multiple If with Countif Statements

In Excel, I have three formulas/statements I'd like to merge into one. I've listed the statements below. Is there a way to merge all three formulas into one? I'd like to learn how to write the logic to do this. Thanks.
=IF(COUNTIF($B:$B,$A2)=1, "MATCH")
=IF(COUNTIF($B:$B,$A2)>1, "DUPLICATE")
=IF(COUNTIF($B:$B,$A2)<1, "NO MATCH")
The syntax of the IF function is IF(true-false-condition, value-if-condition-true, value-if-condition-false) (where either missing value-if defaults to 0).
3-way (or more) IF conditionals can be written by nesting multiple boolean IF's, for example:
=IF(COUNTIF($B:$B,$A2)>1, "DUPLICATE", IF(COUNTIF($B:$B,$A2)=1, "MATCH", "NO MATCH"))
Also consider good practice of trapping the default 'else' case. The above answer does not do this, and it assumes your input will always be one of your stated cases (=1, <1 or >1) so omits the final IF condition. In that example this will not error because the evaluations will always return true or false, but this may not behave as expected if an input is a different data type, null set, etc. In the stated answer, this unexpected behaviour will "fail silently" which is a potential issue.
Instead, try:
=IF(COUNTIF($B:$B,$A2)>1, "DUPLICATE", IF(COUNTIF($B:$B,$A2)=1, "MATCH", IF(COUNTIF($B:$B,$A2)<1, "NO MATCH", "ERROR")))
In implementation you would replace "ERROR" with your chosen error handling method.
You could also look at the following Excel functions, as an alternative to nesting multiple IF functions:
SWITCH:
=SWITCH(expression, value1, result1, [default or value2, result2],…[default or value3, result3])
IFS:
=IFS (test1, value1, [test2, value2], ...)
Some of these are newer than others so be sure to test to your version of Excel (and consider compatibility with any other possible users of your file).

How to correct an Excel formula error

=O27&" "&IF(D27<>"",VLOOKUP(D27,성취기준1반!$B$4:$C$19,2)&" ","")&IF(E27<>"",VLOOKUP(E27,성취기준1반!$E$4:$F$19,2)&" ","")&IF(F27<>"",VLOOKUP(F27,성취기준1반!$H$4:$I$19,2)&" ","")&IF(G27<>"",VLOOKUP(G27,성취기준1반!$K$4:$L$19,2)&" ","")&IF(H27<>"",VLOOKUP(H27,성취기준1반!$N$4:$O$33,2)&" ","")&IF(I27<>"",VLOOKUP(I27,성취기준1반!$Q$4:$R$33,2)&" ","")&IF(J27<>"",VLOOKUP(J27,성취기준1반!$T$4:$U$33,2)&" ","")&IF(K27<>"",VLOOKUP(K27,성취기준1반!$W$4:$X$33,2)&" ","")&IF(L27<>"",VLOOKUP(L27,성취기준1반!$Z$4:$AA$33,2)&" ","")&IF(M27<>"",VLOOKUP(M27,성취기준1반!$AC$4:$AD$19,2)&" ","")&P27
this is working code
=O28&" "&IF(D28<>"",VLOOKUP(D28,성취기준1반!$B$4:$C$19,2)&" ","")&IF(E28<>"",VLOOKUP(E28,성취기준1반!$E$4:$F$19,2)&" ","")&IF(F28<>"",VLOOKUP(F28,성취기준1반!$H$4:$I$19,2)&" ","")&IF(G28<>"",VLOOKUP(G28,성취기준1반!$K$4:$L$19,2)&" ","")&IF(H28<>"",VLOOKUP(H28,성취기준1반!$N$4:$O$33,2)&" ","")&IF(I28<>"",VLOOKUP(I28,성취기준1반!$Q$4:$R$33,2)&" ","")&IF(J28<>"",VLOOKUP(J28,성취기준1반!$T$4:$U$33,2)&" ","")&IF(K28<>"",VLOOKUP(K28,성취기준1반!$W$4:$X$33,2)&" ","")&IF(L28<>"",VLOOKUP(L28,성취기준1반!$Z$4:$AA$33,2)&" ","")&IF(M28<>"",VLOOKUP(M28,성취기준1반!$AC$4:$AD$19,2)&" ","")&P28
this is doesn't workin code.
Why doesn't it work?
This is not an answer in terms of a solution, but an answer in terms of the method you could employ to find and solve the issue. Mainly because you have not provided a working verifiable example, data or detail of the actual error.
First I would remove the vlookups and replace them with the expected results - if that then functions as it should then each of the vlookups needs to be tested, if not then check the detail of the function.
Appreciate if you can assist by explaining.. "why this doesn't work?" part. It is an error message or the the expected value is _ but I got _ instead.. (:
One thing I noticed is that you don't define what will be the outcome if D28 is "". If you don't define it, it'll return 'FALSE' value instead of a String/text.
In your IF() function, you only say IF(d28<>"",<DisplayValueFrom성취기준1반>) it should be IF(d28<>"",<DisplayValueFrom성취기준1반>,<DisplaySomeThingElse>)

Evaluate method to get result for notes web view

I am using evaluate function in lotusscript to get a value of certain expression.
The formula is working fine when kept in the column of a view, but as soon as it is passed in evaluate, it is throwing error as "Error in evaluate macro", might be I am using wrong suntax.
Set Eval= Evaluate({#Text(#If(#Member(#Subset(txtRejectedApprovers;-1);txtApprover1:txtApprover2:txtApprover3:txtApprover4)-#Member(#Name([CN];txtApprovedApprovers[n]);txtApprover1:txtApprover2:txtApprover3:txtApprover4)>0;"1";"0")))},foundDoc)
txtApprover1 and other fields are coming from foundDoc document.
First thing. You shouldn't use such complex evaluate statement because if there are errors or unexpected results its very difficult to find the reason.
I think your error is one bracket to much at the end of your statement. Here is the code which doesn't return the error:
Set Eval= Evaluate({#Text(#If(#Member(#Subset(txtRejectedApprovers;-1);txtApprover1:txtApprover2:txtApprover3:txtApprover4)-#Member(#Name([CN];txtApprovedApprovers[n]);txtApprover1:txtApprover2:txtApprover3:txtApprover4)>0;"1";"0"))},foundDoc)

Resources