I have 3 columns in excel that track when someone answered a call by date. Each person is called up to 3 times, hence the 3 columns. I am trying to count the number of people that answered in July, so the first two columns could be pre-July, or the first column could be in July. My data looks a little like this.
A B C D
1 1st Call 2nd Call 3rd Call July
2 01/06/15 12/06/15 22/06/15 No
3 01/06/15 15/06/15 02/07/15 Yes
4 14/06/15 02/07/15 Yes
5 14/06/15 03/07/15 Yes
6 05/07/15 Yes
So regardless of whether they answered after 1, 2, or 3 attempts, if any of the 3 columns is in July it returns "Yes".
I have tried this formula,
=IF(A2="", "", IF(COUNTIF(A2:C2, month=7)>0, "Yes", "No"))
and
=IF(A2="", "", IF(COUNTIF(A2:C2, MONTH(A2:C2)=7)>0, "Yes", "No"))
But to no avail. Does anyone know how to achieve this?
EDIT
I have realised since I can use the following,
=IF(A2="","", IF(MONTH(A2)=7, "Yes", IF(MONTH(B2)=7, "Yes", IF(MONTH(C2)=7, "Yes", "No"))))
However i'm still curious if my first attempt is achievable.
Yes, you can do what you're attempting with a simple tweak to how you are declaring your 'array' of possible responses:
=OR(IF(A2="", "", IF(Month(A2:C2))=7, TRUE, FALSE)))
You will need to confirm this with CTRL + SHIFT + ENTER, rather than just ENTER. It will work as you are intuiting, by running over each cell with the formula If(Month(CELL)>0, TRUE, FALSE). It then gives us an array of responses, depending on the results. [something like {TRUE, FALSE, TRUE}].
Note that I needed to change "yes" and "no" to TRUE / FALSE, because then we can wrap the whole thing in an OR statement. Otherwise, it's hard to pick out from your array of "yes"'s and "no"'s whether any of them are "yes". You can, if you need to, wrap this whole thing in an IF formula to convert TRUE to "yes", like so:
=IF(FORMULA ABOVE,"yes","no")
Why not just use an Or statement? =if(or(month(a2)=7,month(b2)=7,month(c2)=7),"Yes","No"). Then, you can use a countif to count how many "Yes" answers you have.
As for whether your first method would work, AFAIK it won't as the array in the formula won't work. Also, it's a little "overkill" to use an if countif > 0, then ... since all you want to know is if ANY of them are July, you could just use the above Or() statement.
Related
Hoping someone smarter than myself can help:
Column F contains either of the words below, and I want to excel formula to return whether the data is "White" or "Pink"
Ban
Bandearg
=IF(ISNUMBER(SEARCH("Ban",F2)),"White",IF(ISNUMBER(SEARCH("Bandearg",F2)),"Pink")
The problem is that everything returns as "White" as it is finding "Ban" in both. Presume I am using the formula wrong.
Bán is the Irish for White and Bándearg is the Irish for Pink!
As per my comment, simply swap them around:
=IF(ISNUMBER(SEARCH("Bandearg",F2)),"Pink",IF(ISNUMBER(SEARCH("Ban",F2)),"White"))
ISNUMBER checks wheather or not SEARCH returns a number (meaning the substring is found starting at that index/position) or an #VALUE error. In the first case, it will return TRUE, otherwise FALSE continueing with the second nested IF. Note that this formula will return FALSE if "Ban" isn't found at all.
Maybe just simply add a space behind the criteria and the result value, and your formula become :
=IF(ISNUMBER(SEARCH("Ban ",F2&" ")),"White",IF(ISNUMBER(SEARCH("Bandearg ",F2&" ")),"Pink"))
If those words are all that the cell contains, you can simply use:
=IF(A1="Ban","White",IF(A1="Bandearg","Pink",""))
or, in later versions of Excel (2019+ or O365):
=IFS(A1="Ban","White",A1="Bandearg","Pink",TRUE,"")
All of the methods that I've used have 2 answer values (True or False).
How can I get the following with a formula?
If A1=1 then it's 11, if A1=2 the answer is 22, if A1=3 then it's 33, if A1=4 it's 44.
If the value your are evaluating is in cell A1, then the nested function would be as follows:
IF(A1=1,11,IF(A1=2,22,IF(A1=3,33,IF(A1=4,44,""))))
I put the 2 double commas at the end so the formula returns a blank instead of false.
I don't know if that's what you are asking about, but you can make multiple (nested) IF statements in one. For example:
IF(1=2;TRUE;IF(2=2;TRUE;FALSE))
You just put another IF in the FALSE part of IF statement. If that's not it, can you give a piece of the statement you tried and precise more what do you want?
=IF(AND(INT(A1)=A1,A1<=4,A1>=1),A1*11,"")
Now the above works for the condition you placed in your example, however if one were to go by your title alone you have a couple of options you could go with.
You first Option would be nested IF statements. Like you said each IF function has TRUE or FALSE. The trick is to put another IF function in for the TRUE result and another in for the FALSE results
IF(CHECK1, IF(CHECK2, TRUE2, FALSE2),IF(CHECK3, TRUE3, FALSE3))
The above give 4 potential results based on only 3 checks. Another option would be to do a check and supply a value for a TRUE result and another IF for a false result. Keep repeating the process. Conversely you could go the same route flipping TRUE FALSE option. It might look something like this:
IF(CHECK1, TRUE1, IF(CHECK2, TRUE2, IF(CHECK3, TRUE3, FALSE3)))
FALSE3 would be the result of all previous checks failing.
So for your case, your nested IF could look like (assuming the only valid entries are 1, 2, 3 and 4):
IF(A1=1,11,IF(A1,2,22,IF(A1=3,33,44)))
OR
IF(ISODD(A1),IF(A1=1,11,33),IF(A1=2,22,44))
and there are other options to work through the logic. there are also other checks you could be doing and results being displayed if your entries in A1 were not limited to the integers 1,2,3 and 4.
Now because you example is using the sequential integers 1,2,3 and 4 you could also use the CHOOSE function. Alternatively if you can make your criteria evaluate to sequential integers stating at 1 the CHOOSE function would work as well. Supply choose with an integer as the first argument and it will return the corresponding argument in the list that follows
CHOOSE(ARGUMENT,RESULT1, RESULT2,...,RESULTn-1, RESULTn)
In your case it would look something like:
CHOOSE(A1,11,22,33,44)
If you can not get sequential numbers for whatever reason and the gap is numbers is small and you are in the low integer count, you could leave a gap in results by providing "", or 0). lets say you has 1,3 and 4 as potential arguments, then your choose might look like:
CHOOSE(A1,11,"",33,44)
=IF(A1<>"",INDEX({11;22;33;44},A1),"")
=IF(AND(ISNUMBER(A1),A1<=4),A1*11,"")
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="".
Hi I am trying to get this to work and I have for the most part but missing one piece I want to add. So far I am using this
=IF(OR(AND(G2="Received", C2<>0),AND(G2<>"Received",C2=0)), "PASS", "FAIL")
What I want to happen is to add that if the item is shipped status but not received in another system but the shipment was within 1 calendar day then set the field to say review other wise if its older than one day say fail.
if G2 is "received" and C2 is not 0 then pass otherwise fail
if G2 is not "received" and C2 is 0 then pass otherwise fail
if G2 is ""Shipped" and C2 is not zero and X2 less than 1 day from current date then REVIEW otherwise fail
I would write this exactly as you have it in that last paragraph, and drop the "OR" from your original IF formula:
=IF(AND(G2="Received",C2<>0), "PASS", If(AND(G2<>"Received", C2=0), "Pass", If(AND(G2="Shipped", C2<>0), "Pass", "Fail")))
If it gets more complicated then that, then consider a UDF to keep your sanity in check.
Also, since each one of these three conditions is mutually exclusive, you could refactor this thing down into a boolean statement:
=(G2="Received")*(C2<>0) + (G2<>"Received")*(C2=0) + (G2="Shipped")*(C2<>0)
This will return True or False instead of Pass or Fail. It's a little shorter and doesn't rely on nested if's so adding more combinations of conditions should be easier in the future.
I missed that last date requirement. Updated statement:
=IF(AND(G2="Received",C2<>0), "PASS", If(AND(G2<>"Received", C2=0), "Pass", If(AND(G2="Shipped", C2<>0, Today()-x2<=1), "REVIEW", "Fail")))
So... just added an extra condition in the last AND() here.
I need to use a specific time, so far I had this
=IF(AND(TIME(15,45,0)<=(AW15=$A$11,$A$13)),IF(AND(TIME(15,45,0)>=(AW16=$A$13,$A$15))
So if before 15:45:00 I need for it to equal this logical test AW15=$A$11,$A$13 and if after 15:45:00 to equal to AW16=$A$13,$A$15.
Hope it makes sense and thanks in advance.
So it sounds like you are trying to write a nested IF statement. That is, IF A is true, THEN IF B is also true THEN return result 1, otherwise (A true, but B not true) return result 2, otherwise (A not true, B not tested) return result 3.
In Excel, this would be written as follows:
=IF(Parameter1=Condition1,IF(Parameter2=Condition2,Result1,Result2),Result3)
Applying it to your scenario, I think you are aiming for this:
=IF(TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) < TIME(15,45,0),
IF(AW15=$A$11,$A$13,"Condition1.2"),
IF(AW16=$A$13,$A$15,"Condition2.2"))
Note, some scenarios have not been covered by your statement, so I have written "Condition1.2" and "Condition2.2" which you can replace with additional tests or results to return.
Condition1.2 is where the time is before 15:45, but AW15 did NOT equal A11.
Condition2.2 is where the time is at or after 15:45, but AW16 did NOT equal A13.
You don't have to put anything in those placeholders if you don't want to, but if either of those conditions are ever met then the formula will simply return "FALSE".
Also, if you do not want the test time to be NOW(), then you will need to reference another cell that contains a fixed timestamp for when the row is being worked. NOW() is volatile, which means if you save the spreadsheet before 15:45 but then open it again after 15:45, the results you had already calculated will all change.
If i understand your question correctly, you need to compare the time now to 15:45:00 and make a selection based on that. If so the solution is:
=IF(TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) < TIME(15,45,0),
AW15=$A$11,$A$13, AW16=$A$13,$A$15)
This translates to: If the time now is before 15:45:00 then do AW16=$A$13,$A$15 else do AW16=$A$13,$A$15
If you want to compare the time in a specific cell then substitute the TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) with a cell which has a time for example:
=IF(A1 < TIME(15,45,0),
AW15=$A$11,$A$13, AW16=$A$13,$A$15)