如何轻松否定MS Report中的表达式

本文关键字:表达式 Report MS 何轻松 | 更新日期: 2023-09-27 18:19:56

我正在将一个Crystal报告转换为MS报告。我在Crystal报告中的表达是这样的:

=IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
0,
IIF(Fields!foo.Value Is Not Nothing and Fields!bar.Value Is Nothing,
Fields!foo.Value,
IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Not Nothing,
Fields!bar.Value * -1,
IIF(Fields!foo.Value Is Not Nothing and Fields!bar.Value Is Not Nothing,
Fields!foo.Value,
0
))))

Not在这里不起作用,即使认为文本是蓝色的。

我可以使用Not或类似!的东西吗?或者我必须疯狂地使用IsNothing()

如何轻松否定MS Report中的表达式

您应该能够将表达式简化为:

IIF(Not Fields!foo.Value Is Nothing, 
    Fields!foo.Value,
    IIF(Not Fields!bar.Value Is Nothing,
        Fields!bar.Value * -1,
        0))

EDIT:返回foo。值-条形图。当两者都不为空时,请尝试:

= IIF(Not Fields!foo.Value Is Nothing, Fields!foo.Value, 0) -
  IIF(Not Fields!bar.Value Is Nothing, Fields!bar.Value, 0)

哦,我想好了,我只需要把Not移到表达式的开头。这是我的VB.NET语法错误。来自C#,VB.NET和MS报告对我来说是新的,很抱歉。

=IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
0,
IIF(Not Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
Fields!foo.Value,
IIF(Fields!foo.Value Is Nothing and Not Fields!bar.Value Is Nothing,
Fields!bar.Value * -1,
IIF(Not Fields!foo.Value Is Nothing and Not Fields!bar.Value Is Nothing,
Fields!foo.Value,
0
))))

试试这个:

=IIF((Fields!foo.Value.Equals(System.DBNull.Value)), "YES", "NO")
=IIF((Fields!foo.Value is System.DBNull.Value), "YES", "NO")