Could someone please explain to me what this Excel formula is assessing:
IFNA(IF(OR(S3<>"Complete",AC3<>AD3,AE3<>0),(IF(S3="NA","NA",(VLOOKUP(G3,'FAIR Burn'!$B$3:$M$34,11,FALSE)))),"Complete"),S3)
For example the first part; (OR(S3<>"Complete",AC3<>AD3,AE3<>0), if this condition is satisfied, what value does it take on?
And the second part; (IF(S3="NA","NA",(VLOOKUP(G3,'FAIR Burn'!$B$3:$M$34,11,FALSE)))), what value does it use if satisfied?
The last part of the formula references S3. so if the embedded formula in IFNA () is not met, the value in S3 is used?
Regards,
If you look at the first IF then you have the condition, then the part that is evaluated if condition = true --> in this case another IF-clause, then "Complete" as the false-part
The inner IF checks for S3 = NA, if true the second part is returned, if false the VLOOKUP is returned.
If the result of the first IF returns NA the formula as whole returns S3.
IFNA(
IF ( OR(S3<>"Complete",AC3<>AD3,AE3<>0) ,
(
IF(S3="NA",
"NA",
(VLOOKUP(G3,'FAIR Burn'!$B$3:$M$34,11,FALSE))
)
),
"Complete"
),
S3
)
To answer your questions:
the second/inner IF-clause will be evaluated
IF S3 = "NA" then it returns "NA"
if the embedded formula returns NA value of S3 is returned
Related
In an Excel array formula - when I try to return the first TRUE value from an array using the IF formula, it works as expected if TRUE is the first entry in the array, but not if TRUE appears later
For example, this works and returns "a"
=IF({TRUE,FALSE},{"a","b"})
But this does not work as I would expect - and returns FALSE
=IF({FALSE,TRUE},{"a","b"})
What is the right way to get to "b" in this case?
EDIT
The question I have is - if I have a "logical condition" array with exactly one TRUE value, how do I return the value corresponding to the TRUE.
With numeric values, I can use the SMALL function, for example -
=SMALL(IF({FALSE,TRUE},{1,4}),1)
This returns 4. Is there something equivalent that I can use if I have {"a", "b"} instead of {1, 4} above.
Lots of ways:
with O360:
=XLOOKUP(TRUE,{FALSE,TRUE},{"a","b"})
earlier versions:
=HLOOKUP(TRUE,{FALSE,TRUE;"a","b"},2,0)
=INDEX({"a","b"},MATCH(TRUE,{FALSE,TRUE},0))
I have an excel table see attached picture. I want to find which cells (rows) contain specific hours. To do so I used the if function:
=IF(B2=HOUR("12:00:00");"xx";"yes")
The outcome was not correct. As you can see the outcome was "yes" corresponding to false.. What is the problem ?
In addition, I tried to embed the "and" function, in order to select multiple hours, but the excel prompt error message. The formula I tried in cell B2 is:
=IF(B2=HOUR(AND("12:00:00";"3:00:00");"xx";"yes"))
error message:
contain many conditions
I think you have swapped the arguments in your comparison.
According to the documentation
[HOUR] returns the hour of a time value
If we evaluate your formula step by step, we get:
HOUR("12:00:00") -> 12
B2 = 12 -> false
IF(false; "xx"; "yes") -> yes
To fix this, change your condition to HOUR(B2) = 12.
That should work for a single hour.
If you want to check for multiple hour values, you can use the OR function, as noted in a previous answer, but with modified conditions like this:
IF(OR(HOUR(B2) = 3; HOUR(B2) = 12); "xx"; "yes")
First you just have misplaced the return of the true and the return of the false. Try :
=IF(B2=HOUR("12:00:00");"yes";"xx")
Second, you do not want a logical and but a logical or. And your condition is "if B2 is an hour that is equals to '12:00 and 3:00'" this has no sense. What you want is "if B2 is an hour that is equals to '12:00' or B2 is an hour that is equals to '3:00'". This should look like :
=IF(OR(B2=HOUR("12:00:00"), B2=HOUR("3:00:00")) ; "yes"; "xx"))
Edit : Thanks to Korrat answer I can correct mine. The hour should not be compared like this. You should use the function HOUR on the cell and not on the value.
=IF(OR(HOUR(B2)=12, HOUR(B2)=3) ; "yes"; "xx"))
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="".
How would I combine records if specified columns are the same?
Here's what I have, and the result I'm looking for:
It can be done using array formulas if you don't mind them being big and ugly. This example should do what you're looking for. In case of duplicate entries, it simply takes the last defined value (Prog instead of Programmer for Kevin Moss):
Enter the following formula into C11 and D11, then press CTRL+SHIFT+ENTER to apply the array formula. You can then copy the formula to the rows below as needed.
=INDEX((IF((((($A11=$A$2:$A$7)+($B11=$B$2:$B$7))=2)+(C$2:C$7<>""))=2,C$2:C$7,"")),MAX(IF((IF((((($A11=$A$2:$A$7)+($B11=$B$2:$B$7))=2)+(C$2:C$7<>""))=2,C$2:C$7,""))<>"",ROW($A$1:$A$6),0)))
This breaks down what's happening a little bit, but admittedly it's still pretty opaque, sorry:
=INDEX(
(IF( # This IF statement collects all entries in a data field for a given Fname/Lname combination
(((($A11=$A$2:$A$7) + ($B11=$B$2:$B$7))=2) + (C$2:C$7<>""))=2, # Checks that First and Last Name Match, and Data field isn't empty
C$2:C$7, # Return data field if TRUE
"" # Return empty if FALSE
)),
MAX( # Take the highest index number, use it to select a row from the result of the IF statement above
IF(( # This IF statement returns an index number if the data field isn't empty
IF( # This IF statement collects all entries in a data field for a given Fname/Lname combination (copied from above)
(((($A11=$A$2:$A$7)+($B11=$B$2:$B$7))=2)+(C$2:C$7<>""))=2,
C$2:C$7,
"")
)<>"", # End of conditional statement
ROW($A$1:$A$6), # Value if TRUE (ROW used as an incrementing counter)
0 # Value if FALSE (0 will be ignored in the MAX function that uses this result)
)
)
)
I am trying to write a formula to include multiple criteria and can't seem to get it right.
The formula works as is however I need to include "SHOT10","SHOT20", "SH15" and "SH20"
=IF(AND(C5194="SHOT15",H5194="",I5194=""),E5194,"")
Can someone assist me with modifying the above formula?
The AND(C5194="SHOT15",H5194="",I5194="") is equivalent to saying:
C5194="SHOT15" And H5194="" And 15194=""
So what you have in VBA code is:
If C5194="SHOT15" And H5194="" And 15194="" Then
ActiveCell = E5194
Else
ActiveCell = ""
End
You can use AND( and OR( to specify different parameters.
For example, If I want to pickup 3 different values in 'A1', but make sure that 'B1' and 'C1' are blank, I can use:
=IF(AND(OR(A1="A",A1="B",A1="C"),B1="",C1=""),"True","False")
So in your case specifically:
The issue now is that I now need to also consider SHOT10, SHOT20, SH15 and SH20 as well. Meaning that if either SHOT15, SHOT10, SHOT20, SH15 or SH20 appears in C5194 and H5194 is blank and I5194 is also blank then return the value of E5194 else return blank. The key is that all the conditions must be met for the value of E5194 be returned
Your formula becomes:
=IF(AND(OR(C5194="SHOT15",C5194="SHOT10",C5194="SHOT20",C5194="SH15",C5194="SH20"),H5194="",I5194=""),E5194,"")
Edit: Shorten Using an array constant per barry houdini:
=IF(AND(OR(C5194={"SHOT15","SHOT10","SHOT20","SH15","SH20"}),H5194="",I5194=""),E5194,"")
=IF(
AND(
OR( C5194="SHOT10", C5194="SHOT15", C5194="SHOT20", C5194="SH15", C5194="SH20" ),
H5194="",
I5194=""
),
E5194,
""
)