Solved

A Number is required here - error in Formula

Posted on 2004-08-11
3
2,260 Views
Last Modified: 2010-08-05
Hi All,
Sorry about the basic question but I am new to Crystal


I have a lot of Null entries and I wish to display a string where a entry is null.  I am tryiang the Formula below but it keeps coming back with the error message " a number is required here"

stringVar Message := "Patient to seen or time seen not recorded";

If not Isnull({@Seen Date-Time})
then
(
DateDiff ("n",{@Referral Date-Time} ,{@Seen Date-Time} )
)
else
Message;

Does anyone have any idea I might do this??

Thanks a million,
Nicky
0
Comment
Question by:NickyNin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Expert Comment

by:GJParker
ID: 11774666
Your problem here is that crystal functions will only allow you to return one data type.

In your formula if the field is null then the calculation returns a number where as if the field is null you are attempting to return  a string.

One way around this would be to convert the Datediff calculation to a string i.e.

stringVar Message := "Patient to seen or time seen not recorded";

If not Isnull({@Seen Date-Time})
then
(
ToText(DateDiff ("n",{@Referral Date-Time} ,{@Seen Date-Time} ))
)
else
Message;

Gary
0
 

Author Comment

by:NickyNin
ID: 11781826
Thanks for your reply!!

Unfortunately I need the result to be a number as I then use this number in a calculation.  It tells me that the "a number is required here"

I have tried to convert it back into a number ( see Below) but I get the error message " The string is non numeric"


if IsNull ({@DateDiff})
then 0
else if ToNumber({@DateDiff}) < 10
then -6
else if ToNumber({@DateDiff}) in 10 to 60
then -5
else if ToNumber({@DateDiff}) in 60 to 120
then -4
else if ToNumber({@DateDiff}) in 120 to 240
then -3
else if ToNumber({@DateDiff}) > 240
then -2
else 0
0
 
LVL 19

Accepted Solution

by:
GJParker earned 125 total points
ID: 11781876
Try This

If IsNumeric({@DateDiff})) Then
   if ToNumber({@DateDiff}) < 10 then -6
   else if ToNumber({@DateDiff}) in 10 to 60 then -5
   else if ToNumber({@DateDiff}) in 60 to 120 then -4
   else if ToNumber({@DateDiff}) in 120 to 240 then -3
   else if ToNumber({@DateDiff}) > 240 then -2
Else
   0

Gary

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Crystal image Object type? 7 55
Analyze Shared Variable? 7 44
CTRL P does not work on Crystal Report Viewer 7 45
Crystal Report with Dynamic Page Headers? 5 37
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question