Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This should be a simple IF formula...but it isnt! 1

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

I have a simple formula that i want to return either red or blue as the font colour.

Here goes....(in normal speak first!)
If offered calls <1000 and ASA <20 then blue else red
If offered calls >=1000 and <2000 and ASA is <50 then blue else red
If offered calls >2000 and ASA <80 then blue else red

I have entered the following code into the Font Colour in the Format editor box...

if {PER_APPL.AP_CALLS_OFFRD} <= 1000 and {@AvgSpeedAnswer} <=20 then blue else
if {PER_APPL.AP_CALLS_OFFRD} > 1000 and {PER_APPL.AP_CALLS_OFFRD} <= 2000 and {@AvgSpeedAnswer} <51 then blue else
if {PER_APPL.AP_CALLS_OFFRD} > 2000 and {@AvgSpeedAnswer} <=80 then blue else red
But it doesnt work!!!

Can any one see why not and what do i do to get what i want??

Many thanks in advance

Steven
 
Hi,

Try using clarifing the logic to make it easier to trace:

Code:
if 
 ({PER_APPL.AP_CALLS_OFFRD} <= 1000 and  {@AvgSpeedAnswer} <=20 )
or
({PER_APPL.AP_CALLS_OFFRD} > 1000 and {PER_APPL.AP_CALLS_OFFRD} <= 2000 and {@AvgSpeedAnswer} <51 )
or
({PER_APPL.AP_CALLS_OFFRD} > 1000 and {PER_APPL.AP_CALLS_OFFRD} <= 2000 and {@AvgSpeedAnswer} <51 )
then 
crBlue
else 
 crRed


It should be easy then to remove one or more OR clauses to see which one causes it to not work (Since you didn't specify what was wrong, I cannot be more specific)

[profile]
 
Turkbear has the right of it. Better formatting can help.
Code:
if {PER_APPL.AP_CALLS_OFFRD} <= 1000 and 
   {@AvgSpeedAnswer} <=20 then blue 
else 
  (if {PER_APPL.AP_CALLS_OFFRD} > 1000 and
     {PER_APPL.AP_CALLS_OFFRD} <= 2000 and   
     {@AvgSpeedAnswer} <51 then blue 
   else
      (if {PER_APPL.AP_CALLS_OFFRD} > 2000 and 
          {@AvgSpeedAnswer} <=80 then blue 
       else red
      )
  )
//could also be written as case statement
globalvar isblue := 
  select {PER_APPL.AP_CALLS_OFFRD} 
  case 1-1000    : {@AvgSpeedAnswer} <=20
  case 1001-2000 : {@AvgSpeedAnswer} <51
  case 2001-9999 : {@AvgSpeedAnswer} <=80
  default : no
if isblue then blue else red
 
Formula may be falling over if one of your fields is null, try adding some tests for nulls at the begining.

eg
if isnull({PER_APPL.AP_CALLS_OFFRD}) then green else
if isnull({@AvgSpeedAnswer}) then yellow ......

This would then identify if nulls were a problem.

Ian


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top