I am using this formula:
IF((AND(H11<>"",L11<>""),"Both",IF(AND(H11<>"",L11=""),"First"),IF(AND(H11="",L11<>""),"Second"))
I have two columns, if both columns are filled then write 'Both' in the 3rd column, if the first column is filled but the second is blank then label the 3rd column 'First', if the First column is blank and the second is filled then label the third column as 'Second'
What am I doing wrong here?
My error shows the following:
Any help would be appreciated.
THANKS!
As I mentioned in my comment above your Parentheses are all over the place. You open some and close them at random places elsewhere. You really have to spend the time to step through complex statements like this and insure that you have your parentheses properly lined up.
I think this should work for you:
IF(AND(H11<>"",L11<>""),"Both",IF(AND(H11<>"",L11=""),"First",IF(AND(H11="",L11<>""),"Second")))
I like to use a program like Notepad++ that will highlight matching parentheses when you hover over one:
For instance, hovering over the second parentheses just before that first AND() you will see that the closing parentheses is WAY at the back of the statement. Surely that doesn't make sense since that first parentheses in the statement would have to occur after it.
When I get in a real pickle with nested parenthetical statements like this I like to rewrite it using new-lines and indentation. It highlights issues pretty quick:
IF(
(
AND(
H11<>"",
L11<>""
),
"Both",
IF(
AND(
H11<>"",
L11=""
),
"First"
),
IF(
AND(
H11="",
L11<>""
),
"Second"
)
)
And you can see, again, that there is stuff that isn't where it belongs and at least one of the opening parentheses is lacking it's closing parentheses.
The structure should be like the following. The original formula has several errors, 2nd and 3rd IF do not have valuse for false
IF(
(AND(H11<>"",L11<>""),
"Both",
IF(
AND(H11<>"",L11=""),
"First",
IF(
AND(H11="",L11<>""),
"Second",
"none"
)
)
)
Related
I have a dataset that contains all baseball games played for numerous years. I am attempting to create win/loss streaks. I want the formula to check that the team, and the year remain constant while a decision is made based on if the team won or not. I have the data sorted by Team, and the dates are chronological. Previously I had used a nested if statement when I just had the data for one year. The formula that I am attempting to use is
=IF(M6=M5, IF(C6=C5, IF(G6="W",1+R5,0)), IF(G6="W",1,0), IF(G6="W",1,0)
=IF(Team=AboveTeam, If(Year=Aboveyear, If(Result=win, 1+abovewinsteak)), IF(Result=win, 1, 0), IF(result=win,1,0)
But I am getting the error that I have too many arguments. Any help would be much appreciated.
The IF statement with the condition C6=C5 is the one that had one two few arguments. You can try it this way.
=IF(M6=M5, IF(C6=C5, IF(G6="W",1+R5,0), IF(G6="W",1,0)), IF(G6="W",1,0))
Here's a rewritten version with fewer if statements and no duplication
=IF(G6="W",1+( IF(AND(M6=M5,C6=C5),R5,0)), 0)
IF( Result=Win, 1 + ( IF ( Team=AboveTeam AND Year=AboveYear, AboveWinStreak, Year or Team don't match so start over at 0 ), 0 because Result=Loss )
The top level ‘IF’ statement has too many arguments. The last two IFs seem out of place to me. I’m not sure of your logic, but assuming that you have a bunch of conditions that need to be met, the excel ‘IF’ formula signature is of the form:
IF(condition, if_true, if_false)
So you always need to put the next ‘IF’ in place of either ‘if_true’ or ‘if_false’. Within each parentheses pair there should be just 3 arguments.
Also, the 2nd IF has too few arguments (no ‘if_false’).
So, assuming that the last two IFs are in error; I think your formula should be:
=IF(M6=M5, IF(C6=“W”, IF(C6=C5, 1+R5, 1), 0), 0)
I have this formula:
=IFERROR(
(
(
IFERROR(INDIRECT($A6&"!$E$15");"")
+IFERROR(INDIRECT($A6&"!$E$29");"")
+IFERROR(INDIRECT($A6&"!$E$43");"")
+IFERROR(INDIRECT($A6&"!$E$57");"")
+IFERROR(INDIRECT($A6&"!$E$71");"")
+IFERROR(INDIRECT($A6&"!$E$84");"")
)
/6);"")
When any of these IDIRECTS return a blank value, I get an #VALUE! error (without the first IFERROR). Each individual line works just fine, and when putting them in cells individually, I can average them fine. If I remove the /6 part of this formula however, and wrap the lines with an AVERAGE-formula, I get the #VALUE! error also.
How can I proceed?
EDIT, SOLUTION FOUND (Thanks Mrig):
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A7&"!$E$15"));INDIRECT($A7&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$29"));INDIRECT($A7&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$43"));INDIRECT($A7&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$57"));INDIRECT($A7&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$71"));INDIRECT($A7&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A7&"!$E$84"));INDIRECT($A7&"!$E$84");0)
)/
(
COUNTIF(INDIRECT($A7&"!$E$15");">=0")
+COUNTIF(INDIRECT($A7&"!$E$29");">=0")
+COUNTIF(INDIRECT($A7&"!$E$43");">=0")
+COUNTIF(INDIRECT($A7&"!$E$57");">=0")
+COUNTIF(INDIRECT($A7&"!$E$71");">=0")
+COUNTIF(INDIRECT($A7&"!$E$82");">=0")
)
);"")
The COUNTIF's bascially replaces the number "6" in the original code, and checks which of the INSNUMER's (instead of IFERROR's) that isn't blanks, so anything that's 0% or higher (actual value) will be counted, to get to the true average.
Using the suggestions above in the comments, you can use IF(ISNUMBER()) instead of IFERROR()
=IFERROR(
(
(
IF(ISNUMBER(INDIRECT($A6&"!$E$15"));INDIRECT($A6&"!$E$15");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$29"));INDIRECT($A6&"!$E$29");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$43"));INDIRECT($A6&"!$E$43");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$57"));INDIRECT($A6&"!$E$57");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$71"));INDIRECT($A6&"!$E$71");0)
+IF(ISNUMBER(INDIRECT($A6&"!$E$84"));INDIRECT($A6&"!$E$84");0)
)/6);"")
I started off thinking that your 'stagger' was 14 rows so I went with this array formula:
=AVERAGE(IF(MOD(ROW(E15:E84), 14)=1, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
... but your 'stagger' is not a consistent 14 rows; the last gap is 13 rows so I modified it to this:
=AVERAGE(IF(ROW(15:84)={15,29,43,57,71,84}, IF(ISNUMBER(INDIRECT($A6&"!E15:E84")), INDIRECT($A6&"!E15:E84"))))
That produces a true average without zero substitution on blank cells while discarding text values.
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="".
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")
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,
""
)