0
votes

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?

3

3 Answers

0
votes

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") & "%"))
0
votes

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)
)

enter image description here

0
votes

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)