Andrea Capone
Andrea Capone

Reputation: 11

Crystal Report if-then statement

i have a database that contain some measure. The problem is that the measure are saved in the main units (for example, 1 mV is saved as 0.001 V). Now I use crytal report to generate a report with these measure, but I want to convert 0.001V into 1mV.

How can i do this?

I tryed with:

if lcase({database.result_type})="eval" then
  {@Test_Result}   
else
(
    if {database.measure}<0.001 then
      {database.measure}*1000000 & "uV"
    else if {database.measure}<1 then
      {database.measure}*1000 & "mV"
    else if {database.measure}<1000 then
      {database.measure} & "V"
);

but it doesn't work. The first IF is to understand if it's a PASS/FAIL test or a measurement.

How can i do?

Upvotes: 1

Views: 44151

Answers (1)

craig
craig

Reputation: 26262

You formula needs to produce a consistent result, either a string or a number, but not both:

if lcase({database.result_type})="eval" then
  // assuming that this is a string
  {@Test_Result}   
else
(
    // assuming that `{database.measure}` is a number
    if {database.measure}<0.001 then
      ToText({database.measure}*1000000) & "uV"
    else if {database.measure}<1 then
      ToText({database.measure}*1000) & "mV"
    else if {database.measure}<1000 then
      ToText({database.measure}) & "V"
);

Upvotes: 3

Related Questions