I am using excel 2010 and want to give out 1 if it's true and 0 if it's false for a given string.
I tried:
=IF((EXACT(G2;"V") OR EXACT(G2;"K"));"1";"0")
However, this always gives me an error.What's wrong with this formula?
I appreciate your replies!
That's not how you use the OR formula. Try this:
=IF(OR(EXACT(G2;"V");EXACT(G2;"K"));"1";"0")
It is indeed:
OR(Test; Test; Test; ...)
Note:
I'm not sure why you used "1" and "0", but you can drop the quotes if you don't mind having numbers.
You might also simply use:
=OR(EXACT(G2;"V");EXACT(G2;"K"))
To get the result as TRUE or FALSE, or if you want to get 1 or 0...
=OR(EXACT(G2;"V");EXACT(G2;"K"))*1
Related
I am working on a document where I need to be able to test multiple options in an if statement to see if one of them are true to decide if a paragraph displays on the document. I have been trying to figure out why my OR formula is not returning a value for me to test and I am not sure why it is not showing anything when it is updating.
I have inserted a field and added a formula within that field that I am hoping will work with my If statement to show the proper paragraph contens.
When I use an Or statement, even one as simple as { OR(1=1) } and update and toggle the field I get no result. From what I have read I should get a 1 or a 0, but I don't seem to get either of these results. The line just ends up blank. When I test it with my If formula it always shows the false result, even when the Or contains a true result.
The formula I am currently working with is:
{ IF{ OR("$event.eventType.name}" = "Birthday", "$event.eventType.name}" =
"Conference" } "Yes" "No" }
If I update and toggle the Or field it shows blank, no result either true or false, and makes the If formula show as false event on results where it should show true. As I mentioned above I even tried setting it to 1=1 and still could not get it to show as true. Not sure if there is something I am missing in working with the formula.
Any suggestions would be appreciated.
It's not clear from your post what $event.eventType.name is. Presumably it's a field generated by an Addin. In that case, you should be able to use something like:
{IF{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0}# 0}> 0 "Yes" "No"}
or:
{={IF{$event.eventType.name}= "Birthday" 1 0}+{IF{$event.eventType.name}= "Conference" 1 0} \# "'Yes',,'No'"}
Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. If your fields are a kind of mergefield, you'll need to insert 'MERGEFIELD ' at the start of each one, thus:
{MERGEFIELD $event.eventType.name}
I have a drop down with three different choices. I'm trying to make the below cell have a question depending which drop down selection you choose. so far it works with one statement
=IF($B$2="A","First","").
That works, but when i add an or statement it does not work
=IF($B$2="A","First","") OR IF$B$2="B","Second","")
This does not work how can i change this so i cave this statement work for three choices with the formula in one cell.
=IF($B$2="A","First", IF($B$2="B", "Second", IF($B$2="C", "Third","???")))
or
=IFERROR(VLOOKUP(B3,{"A","First";"B","Second";"C","Third"},2,FALSE),"???")
You cannot use OR function in Excel that way. Have a look at this: https://exceljet.net/excel-functions/excel-or-function
You could trying using nested IF statements OR you could use some other method (like a VLOOKUP)
Nested If would be something like this:
=IF($B$2='A', 'First', IF($B$2='B', "Second", ""))
The "nested ifs" is your best option.
=IF($B$2="A","First","")
=if($B$2=A,"condition 1","condition 2")
Condition 1 is true, i.e. $B$2=A
Condition 2 is false, i.e. $B$2 does not equal <> A
The way to nest the ifs is to include it instead of "condition 1" or "condition 2".
So =if($B$2=A,if($B$2=B,"condition 2", "condition 3"),"condition 1")
$B$2=A and $B$2=B are both true then condition 2
$B$2=A is true but $B$2=B is not true then condition 3
$B$2=A is not true then condition 1
This is the logic behind nested ifs. You can expand this.
Could somebody tell me what I'm doing wrong in this query to get a calculated column?
IIf(Left([VIN Number],2)="1F" OR "2F" OR "3F" OR "1L” OR “2L” OR “NM”,”Food”,"Comp")
It's giving me error saying "you may have entered an operand without an operator"
You can't have a compound condition like ...
Something = "a" OR "b"
You would have to repeat the Something = after OR ...
Something = "a" OR Something = "b"
For your query's IIf() expression, an In() list containing the match values would be more concise ...
IIf(Left([VIN Number],2) IN ("1F", "2F", "3F", "1L", "2L", "NM"), "Food", "Comp")
Beware your code sample includes typesetting quotes (“ and ”). Make sure you use plain quotes (") in your real code.
The OR operator doesn't work how you expect it to. It requires statements that resolve to TRUE or FALSE on either side of it, so you can't check if something is equal to one of many things like this.
You either need to do:
Iif(Left([VIN Number],2)="1F" OR Left([VIN Number],2)="2F" OR Left([VIN Number],2)="3F"...., "Food", "Comp")
or you need to do:
Iif(Left([VIN Number],2) In("1F","2F", "3F"....), "Food", "Comp")
I am curious as how I can solve this.
I have a column containing product name(columns AQ) and I have created a column to its right showing(column AR) 1 or 0 if it matches.
this is the code :=IF(RIGHT(AQ3;3)="MAX";1;0)
What I wanted to know is... how can I use the AND or OR function to add "BAS"( so it has both "MAX" and "BAS") in the above code?
I tried this but it returned #VALUE.
Failed attempt.IF(RIGHT(AQ3;3)="MAX";1;0);IF(RIGHT(AQ3;3)="BAS";1;0)
Thanks for the answers: How to I use "AND" in this?
You use it as follows:
=IF(OR(RIGHT(AQ3;3)="MAX";RIGHT(AQ3;3)="BAS");1;0)
OR works like that: OR( Expr1 ; Expr2 ; Expr3? ...)
If any of those expressions evaluate to TRUE, then OR returns true.
Your IF syntax will work like this:
=IF(RIGHT(AQ3;3)="MAX";1;IF(RIGHT(AQ3;3)="BAS";1;0))
or an alternative OR version:
=IF(OR(RIGHT(AQ3;3)={"MAX";"BAS"});1;0)
For example:
F2 = VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)
I would like to add in the function that if $L$2 can not be found in the sheet2!$A$2:$G$169, then show "invalid".
May i know how should i modified to code in excel? Thanks.
First test what gets returned if $L$2 cannot be found by putting in a value you know is not in the search set. For example if it returns 0 then:
=IF(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0) = 0, "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
If it returns an error then try something along the lines of
=IF(ISERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0)), "invalid", VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0))
or just
=IFERROR(VLOOKUP($L$2,sheet2!$A$2:$G$169,6,0), "invlaid")