Solved

A Number is required here - error in Formula

Posted on 2004-08-11
3
2,256 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
  • 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Reports CSV data source, field types 6 102
Crystal Report for VS2013 17 105
Help with a Crystal Report Formula - remove time 5 33
Crystal report highlighting 5 38
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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 …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

809 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