string 水晶报表公式工作室布尔条件到字符串

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2641044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 00:42:26  来源:igfitidea点击:

Crystal Reports Formula Workshop boolean condition to string

stringcrystal-reportsboolean

提问by Jay

I'm currently trying to create a report using Crystal Reports that comes with Visual Studio 2008.

我目前正在尝试使用 Visual Studio 2008 附带的 Crystal Reports 创建报告。

I would like to include a field of type boolean on my report that shows a string rather than true or false. The string should contain either contain a or a % sign.

我想在我的报告中包含一个 boolean 类型的字段,该字段显示字符串而不是 true 或 false。该字符串应包含一个或一个 % 符号。

How would I go about doing this in the Formula Workshop?

我将如何在公式工作室中进行此操作?

I've tried things like e.g.

我试过像这样的东西

if {tblAankoopDetails.SoortKorting} = true then "" else "%"

However this never seems to work and results in warnings such as "The formula result must be a number".

然而,这似乎永远不会奏效并导致警告,例如“公式结果必须是数字”。

This should be fairly simple but this is my first go at using Crystal Reports.

这应该相当简单,但这是我第一次使用 Crystal Reports。

Help would be much appreciated.

帮助将不胜感激。

Jay

回答by Claudia

Make sure your SoortKorting field has always true or false. Maybe there's a null and in that case your formula will not work.

确保您的 SoortKorting 字段始终为真或假。也许有一个空值,在这种情况下你的公式将不起作用。

Try with this:

试试这个:

if isnull({tblAankoopDetails.SoortKorting}  ) then 
" "
else
    if {tblAankoopDetails.SoortKorting} =true 
    then "" else "%"

回答by LeBleu

Make sure there is nothing else in the same formula. Usually I see that particular error when a formula sometimes returns a string, and sometimes a number.

确保同一个公式中没有其他内容。通常,当公式有时返回一个字符串,有时返回一个数字时,我会看到那个特定的错误。

Also, you shouldn't need to test for true, so you might try:

此外,您不需要测试是否为真,因此您可以尝试:

if {tblAankoopDetails.SoortKorting} then "" else "%"