Forum Discussion
Excel Baseball 1st Batter Out Formula Help
Safe formula: =IF(AND(E2=1,OR(P2="1B","2B","3B","HR","HBP")),1,0)
Out formula: =IF(AND(E4=1,OR(P4="K","O","ROE")),1,0)
It is only pumping out a 1 if it is that first listed situation (1B or K). Where am I messing up?
For the formulas you've listed, you must continue using the cell to check the values.
This is what the first looks like in function arguments. Notice the logicals beyond 1 don't have TRUE/FALSE returns.
Update the formulas -
safe
=IF(AND(E2=1,OR(P2="1B",P2="2B",P2="3B",P2="HR",P2="HBP")),1,0)out
=IF(AND(E4=1,OR(P4="K",P4="O",P4="ROE")),1,0)
- m_tarlerSep 24, 2024Bronze Contributor
or list them into a SET using the {} like:
Safe formula:=IF(AND(E2=1,OR(P2={"1B","2B","3B","HR","HBP"} )),1,0)Out formula:
=IF(AND(E4=1,OR(P4={"K","O","ROE"} )),1,0)The SET outputs an array over which the OR will be applied. Note using those {} only work on constants so you can't use it on cell reference or variables so if you wanted to compare P4= A1, A2, or A3 then P4= {A1,A2,A3} will NOT work but in that case you could do OR(P4=A1:A3)
but note to Patricks point each comparison must have a complete equation so on the left is P4 then a comparator (=) and then 1 term. if separated by a comma then you need P4= for each case. In my examples the {"K","O","ROE"} is 1 SET and the other example I noted P4=A1:A3 the A1:A3 is 1 RANGE.