0
votes

I am new to Crystal Reports. I have a DB where the Memory Column is being reported in KB. I created a report for my IT director in which he wants that field to be reporting the memory in GB. I tried this formula (based on book I purchased titled 'Beginner's Guide to Crystal Reports 2016')

IF {tblDts.Memory} = "" THEN "N/A" ELSE {tblDts.Memory}*0.4256

The error I get is

A number, or currency amount is required here

and it highlights the {tblDts.Memory} after my ELSE statement.

That field in the database only has numeric values (btw - 0.4256 is the decimal format for 10240, I tried a division statement with the same results so I figured I try a multiplication statement).

What am I doing wrong?

1
Maybe I am going about creating the formula incorrectly? I select the data field in details and right-click on it, select Format Field. I then select the Common tab and click on the x-2 icon towards the right of Display String. Could that be my issue?Szmooz

1 Answers

1
votes

In a conditional statement both IF and ELSE should return same datatype else there will be these kind of errors reported.

Here for IF you are returning string and for ELSE you are returning Number hence the error.

Suggested would be return 0 in case of IF and your calculation in ELSE

IF {tblDts.Memory} = "" 
THEN 0
ELSE {tblDts.Memory}*0.4256

Edit--------------------------------------------------

if IsNumber({tblDts.Memory})
then 
(
ToNumber({tblDts.Memory})*0.4256
)
else
0