简体   繁体   English

SSRS IIF表达式

[英]SSRS IIF expression

In my SSRS report I want PolDiscountPerc textbox from my query to make blank when PolStockCode in a row is empty or empty string, however if PolStockCode contains a value then format PolDiscountPerc textbox to display it as a percentage. 在我的SSRS报告中,当行中的PolStockCode为空或为空字符串时,我希望查询中的PolDiscountPerc文本框为空白,但是,如果PolStockCode包含值,则格式化PolDiscountPerc文本框以将其显示为百分比。

=IIF(IsNothing(Fields!PolStockCode.Value) or Fields!PolStockCode.Value is "", "",(Format(Fields!PolDiscountPerc.Value, "0.00") & "%"))

The problem with following query is that it either does nothing or sets the textbox to blank for every row in the table despite the fact that most of them do contain the PolStockCode. 以下查询的问题是它不执行任何操作或将表中的每一行的文本框都设置为空白,尽管其中大多数确实包含PolStockCode。 Where have i gone wrong? 我哪里出问题了?

is can only be used for comparing to nothing . is只能用于比较nothing you need to use = . 您需要使用=

=IIF(IsNothing(Fields!PolStockCode.Value) or Fields!PolStockCode.Value = "", "",(Format(Fields!PolDiscountPerc.Value, "0.00") & "%"))

Can you try it by removing is to = and make the expression to single unit () . 您可以通过删除is =来尝试将表达式设为单个unit ()吗?

=IIF
(
  (IsNothing(Fields!PolStockCode.Value) or Fields!PolStockCode.Value = "")
  , ""
  ,(Format(Fields!PolDiscountPerc.Value, "0.00") & "%")
)

OR you can format the percentage externally: 或者,您可以在外部设置百分比格式:

=IIF
(
  (IsNothing(Fields!PolStockCode.Value) or Fields!PolStockCode.Value = "")
  , ""
  ,Fields!PolDiscountPerc.Value)
)

在此处输入图片说明

I completely forgot this is an nchar field in the database and it wouldn't be an empty string. 我完全忘记了这是数据库中的nchar字段,它不是空字符串。

Therefore this solved my problem 因此,这解决了我的问题

=IIF((IsNothing(Fields!PolPMStockCode.Value) or Len(Trim(Fields!PolPMStockCode.Value)) = 0), "", Fields!PolDiscountPerc.Value)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM