View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Help/Check my Formula

"revpeachy" wrote:
Please could someone kindly check my formula:

[....]
=IF(G4="","",IF(G4<100%,1,IF(G4=100%,2,IF(G4=111 %,3))))


Conditions are tested left-to-right. If G4 is larger than 111%, it is also
larger than 100%, which is tested first. So the formula would return 2
instead of 3 as you intended.

At a minimum, try:

=IF(G4="","",IF(G4<100%,1,IF(G4<111%,2,3)))

More generally, especially if you might have more conditions to test in the
futu

=IF(G4="","",LOOKUP(G4,{0,1,1.11},{1,2,3}))

That assumes G4 is never negative. If it might be, change 0 to -1E300,
almost the smallest negative number that can be represented and that is easy
to remember.

However, in all cases, you might encounter some surprises if G4 is a
calculated. It might display 100% or 111%, but that is rounded from the
actual value, which might be less.

The following is more reliable:

=IF(G4="","",LOOKUP(ROUND(G4,2),{0,1,1.11},{1,2,3} )

Change ROUND(...,2) to ROUND(...,4) if you format G4 as Percentage with 2
decimal places, for example.