Crystal Report if-then声明

时间:2013-07-27 09:19:59

标签: if-statement crystal-reports report

我有一个包含一些措施的数据库。问题是测量值保存在主要单位中(例如,1 mV保存为0.001 V)。 现在我使用crytal报告生成一个包含这些度量的报告,但我想将0.001V转换为1mV。

我该怎么做?

我尝试过:

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"
);

但它不起作用。第一个IF是要了解它是通过/失败测试还是测量。

我该怎么办?

1 个答案:

答案 0 :(得分:2)

您的公式需要产生一致的结果,字符串或数字,但不能同时产生两者:

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"
);
相关问题