Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Formula Post Reply Post New Topic
Author Message
lbuffett
Newbie
Newbie


Joined: 20 Jan 2017
Online Status: Offline
Posts: 7
Quote lbuffett Replybullet Topic: Formula
    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

Edited by lbuffett - 24 Jan 2017 at 4:46am
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet 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.

IP IP Logged
lbuffett
Newbie
Newbie


Joined: 20 Jan 2017
Online Status: Offline
Posts: 7
Quote lbuffett Replybullet 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
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet 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 ""
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.