水晶报表公式:IsNull + 伊夫

发布于 2024-07-13 01:32:37 字数 888 浏览 7 评论 0原文

这个网站上到处都有这个问题答案的提示,但我问的问题略有不同。

Crystal Reports 在哪里记录了此语法不起作用?

Trim({PatientProfile.First}) + " "
    + Trim(Iif(
        IsNull({PatientProfile.Middle}) 
        , Trim({PatientProfile.Middle}) + " "
        , " "
        )
    )  
+ Trim({PatientProfile.Last})

我知道解决方案是,

If IsNull({PatientProfile.Middle}) Then
    Trim({PatientProfile.First})
        + " " + Trim({PatientProfile.Last})
Else
    Trim({PatientProfile.First})
       + " " + Trim({PatientProfile.Middle})
       + " " + Trim({PatientProfile.Last})

但我们如何知道我们不能使用第一个版本?

IsNull 的文档说

  • 评估当前记录中指定的字段,如果该字段包含空值

,则返回 TRUE,如果表达式为 True,则 Iif 给出

  • [Returns] truePart;如果表达式为 False,则 Iif 给出 [Returns] truePart。 返回值的类型与truePart和falsePart的类型相同。

我想如果你盯着关于“返回值类型”的那一行你就可以明白,但是......

There are hints of the answer to this question here and there on this site, but I'm asking a slightly different question.

Where does Crystal Reports document that this syntax does not work?

Trim({PatientProfile.First}) + " "
    + Trim(Iif(
        IsNull({PatientProfile.Middle}) 
        , Trim({PatientProfile.Middle}) + " "
        , " "
        )
    )  
+ Trim({PatientProfile.Last})

I know the solution is

If IsNull({PatientProfile.Middle}) Then
    Trim({PatientProfile.First})
        + " " + Trim({PatientProfile.Last})
Else
    Trim({PatientProfile.First})
       + " " + Trim({PatientProfile.Middle})
       + " " + Trim({PatientProfile.Last})

but how are we supposed to figure out we can't use the first version?

The documentation for IsNull says

  • Evaluates the field specified in the current record and returns TRUE if the field contains a null value

and Iif gives

  • [Returns] truePart if expression is True and falsePart if expression is False. The type of the returned value is the same as the type of truePart and falsePart.

I suppose if you stare at that line about "type of the return value" you can get it, but...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一瞬间的火花 2024-07-20 01:32:37

<块引用>

Crystal Reports 在哪里记录了此语法不起作用?

我怀疑整个宇宙中是否有足够大的地方来记录水晶报表中不起作用的所有内容......

Where does Crystal Reports document that this syntax does not work?

I doubt there is anyplace large enough in the entire universe to document everything that does not work in Crystal Reports...

情感失落者 2024-07-20 01:32:37

我知道我在这个问题上迟到了好几年,但我在试图弄清楚同样的事情时遇到了这个问题。 有趣的是,我什至无法在 Crystal Reports 文档中找到答案,而是在 链接中找到IBM。

一般来说,如果您使用 Crystal Reports 8.x 或 10.x,ISNULLIIF 不能一起工作。 从网站:

原因

Crystal Reports 8.x 和 10.x 中存在一个缺陷,导致上述公式无法正常工作。 “IIF”和“IsNull”命令不能一起起作用,这包括尝试使用“Not”来修改 IsNull 命令; 例如,IIF(Not IsNull ())。

解决问题

解决方法是使用“If-Then-Else”语句。 例如,

If IsNull({~CRPT_TMP0001_ttx.install_date}) Then "TBD" Else "In Progress"

如果您使用 CR 8.x 或 10.x(我们就是),那么您就不走运了。 当您将多个字段连接在一起并且其中一个字段可能为 NULL 时,这会变得非常有趣。

I know I'm years late on this one, but I came upon this question while trying to figure out the same thing. Funny enough, I couldn't even find the answer in Crystal Reports documentation, but instead in a link to IBM.

Baiscally, if you're using Crystal Reports 8.x or 10.x, ISNULL and IIF don't work together. From the site:

Cause

There is a defect in Crystal Reports 8.x and 10.x that prevents the above formula from working correctly. The 'IIF' and 'IsNull' commands cannot function together, and that includes attempting to use "Not" to modify the IsNull command; for example, IIF(Not IsNull ()).

Resolving the problem

The workaround is to use an "If-Then-Else" statement. For example,

If IsNull({~CRPT_TMP0001_ttx.install_date}) Then "TBD" Else "In Progress"

So if you're using CR 8.x or 10.x (which we are), you're out of luck. It makes it REAL fun when you are concatenating multiple fields together and one of them might be NULL.

眉黛浅 2024-07-20 01:32:37

我认为 CR 评估 IIF 的正确部分和错误部分。 因为你有“Trim({PatientProfile.Middle})”部分,它将根据空值进行评估,CR 公式计算器似乎失败了。

I think CR evaluates both IIFs true and false parts. Because you have "Trim({PatientProfile.Middle})" part there, which will be evaluated aganst null value, CR formula evaluator seems just fail.

划一舟意中人 2024-07-20 01:32:37

尝试这个:

currencyvar tt;
currencyvar dect;
tt :={ship.comm_amount};
dect := tt - Truncate(tt);
tt := truncate(tt);
dect := dect * 100;
if dect = 0 then
UPPERCASE('$ ' + ToWords (tt,0 )) + ' ONLY'
else
UPPERCASE('$ ' + ToWords (tt,0) + ' And ' + ToWords(dect,0)) + ' ONLY ';

try this:

currencyvar tt;
currencyvar dect;
tt :={ship.comm_amount};
dect := tt - Truncate(tt);
tt := truncate(tt);
dect := dect * 100;
if dect = 0 then
UPPERCASE('$ ' + ToWords (tt,0 )) + ' ONLY'
else
UPPERCASE('$ ' + ToWords (tt,0) + ' And ' + ToWords(dect,0)) + ' ONLY ';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文