if statement in formula

D

Derrick

is it possible to do this:

D2 = A2 * if(B1= "1/4 points", A2/4, if(B2="1/8 points", A2/8)) * A3

a b c d
1 LENGTH POSITION HEIGHT ANSWER
2 12 "1/4 points" 24 864
3 12 "1/8 points" 24 432

with my if statement... to avoid writing my formula 3 times... this is a
hugely simplified formula - the actual one is several lines long, and i'd
like to minimize code.
thanks,
 
B

Bob Phillips

This works for me

= A2*IF(B2="1/4 points",A2/4,IF(B2="1/8 points",A2/8))*A2

although it is half the number that you show
 
L

Luke M

While that is a valid formula, if you're dealing with multiple text values
which already contain the number you want, why not do this:

=C2*A2*A2/MID(B2,FIND("/",B2)+1,FIND(" ",B2)-FIND("/",B2)-1)

I'm assuming you wanted to multiply by height (C2) and not A3. Note that you
could now copy this down, and you don't have to worry about all the different
fractions you might have.
 
D

Derrick

luke, thanks for the input - actually, these are text values are from a
validated list, so there's not going to be any variance.. so it will be
easier in the long run... i wont have to look for '1/2.455 points' or
anything like that
 
D

Derrick

ok thanks!
whoops. i made a mistake in writing the formula.. lol the last *A2 should be
*C2... which would explain ur half of my answer.
for some reason i was getting an error when doing my formula, so now that i
know it works, i'll go through it and look.
 
L

Luke M

Ok, thanks for response. You basic formula structure is okay then, just need
to swap the A3 reference out to:

=A2*IF(B2="1/4 points",A2/4,IF(B2="1/8 points",A2/8))*C2
 
J

Jacob Skaria

TRY

=A2^2/(IF(B2="1/4 points",4,IF(B2="1/8 points",8)))*C2

If this post helps click Yes
 
D

Derrick

Jacob-
thanks, and that would work, but the goal was to know if having an if
statment would work - the formula below was a simplified example of one im
working on. so, albeit shorter, quite unneccessary lol.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top