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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is formula not showing the correct ranges 2

Status
Not open for further replies.

morechocolate

Technical User
Apr 5, 2001
225
US
Here is the formula that I have:

if {@NewWal} < 3 then &quot;< 3&quot;
else if ({@NewWal} in 3 to 5) then &quot;3 to 5&quot;
else if ({@NewWal} > 5) or ({@NewWal} <= 7) then &quot;5 to 7&quot;
else if ({@NewWal} > 7) or ({@NewWal} <= 10) then &quot;7 to 10&quot;
else if ({@NewWal} > 10) or ({@NewWal} <= 15) then &quot;10 to 15&quot;
else if ({@NewWal} > 15) or ({@NewWal} <= 30) then &quot;15 to 30&quot;
else if {@NewWal} > 30 then &quot;> 30&quot;

I am using the formula as a group, however the only groups that are appearing are <3, 3 to 5, and 5 to 7. Could someone please tell me what I am doing incorrectly?

Thank You
 
Once Crystal find a true &quot;if&quot; it stops checking the rest of the if - then statements. Because you are using an &quot;or&quot; only one of the conditions must be met. Once the value is greater than 5 (true for the ({@NewWal} > 5) part of the third condition check, your third statement becomes true.

Change your or's to and's.

if {@NewWal} < 3 then &quot;< 3&quot;
else if ({@NewWal} in 3 to 5) then &quot;3 to 5&quot;
else if ({@NewWal} > 5) and ({@NewWal} <= 7) then &quot;5 to 7&quot;
else if ({@NewWal} > 7) and ({@NewWal} <= 10) then &quot;7 to 10&quot;
else if ({@NewWal} > 10) and ({@NewWal} <= 15) then &quot;10 to 15&quot;
else if ({@NewWal} > 15) and({@NewWal} <= 30) then &quot;15 to 30&quot;
else if {@NewWal} > 30 then &quot;> 30&quot;

Mike

 
Using that same principle, if you put the rules in the correct order you could simlify to:

if {@NewWal} < 3 then &quot;< 3&quot; else
if {@NewWal} <= 5 then &quot;3 to 5&quot; else
if {@NewWal} <= 7 then &quot;5 to 7&quot; else ... Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top