简体   繁体   中英

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.

=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. Where have i gone wrong?

is can only be used for comparing to 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 () .

=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.

Therefore this solved my problem

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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