Print Page | Close Window

Formula

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22203
Printed Date: 07 May 2024 at 10:00am


Topic: Formula
Posted By: lbuffett
Subject: Formula
Date Posted: 23 Jan 2017 at 8:40am
Hello;

I am looking to return a code if it is between the following code ranges:

98101-98801

I was thinking something like:

if   {table.field} >= {98101}   and   {table.field} <= {98801}   then "Show"   else "Hide"

Do you think that would work to only return the value if it was between
98101-98801.

LB



Replies:
Posted By: kevlray
Date Posted: 23 Jan 2017 at 12:01pm
The first question is the code field a string or a number.  If it is a number then yes it should work (with slight modification

if   {table.field} >= 98101   and   {table.field} <= 98801   then "Show"   else "Hide"
if it is a string
if   {table.field} >= "98101"   and   {table.field} <= "98801"   then "Show"   else "Hide"

numeric strings can sometimes be a little tricky with ranges and sorting.



Posted By: lbuffett
Date Posted: 24 Jan 2017 at 4:20am
Thank you for the help.

It is a string and I think it is working correct. The problem I am having is that on the report instead of the number (code) showing it displays show or hide depending on whether or not it is in the range.

Any ideas on how to just return the number.

Les


Posted By: kevlray
Date Posted: 24 Jan 2017 at 7:28am
If you want the number on the report then you put that field in the report.  The formula you posted will return either the words Show or Hide.  Or do you want the formula to return the number?  If so, do this.

if   {table.field} >= "98101"   and   {table.field} <= "98801"   then {table.field}   else ""



Print Page | Close Window