简体   繁体   中英

Nested IIF statement in SSRS

I am having a problem with a simple nested IIF statement on SSRS. I am trying to do the second part where if the number is a "-" then it should return a "-" .

=IIF(Fields!fbrt_number.Value < "0",Fields!fbrt_number.Value, "+")

Thanks

It's unclear what you're exactly after. I'm assuming you want to prefix all numbers (including positive numbers and zero) with a sign.

Here's what your code currently does:

  • Compares fbrt_number 's value with the string "0"
  • Depending on the result either show the fields' value, or a plus sign

Are you perhaps after this:

=IIF(Fields!fbrt_number.Value < 0, 
     "-" + Fields!fbrt_number.Value.ToString(),
     "+" + Fields!fbrt_number.Value.ToString())

This will compare the field value to the number 0, and depending on the result prefix a "-" or a "+".

Or, if you want to display just a "+" for positive values, and a "-" for negatives:

=IIF(Fields!fbrt_number.Value < 0, 
     "-",
     "+")

Finally, if you want an empty string for 0 then this will work:

=IIF(Fields!fbrt_number.Value < 0, 
     "-",
     IIF(Fields!fbrt_number.Value > 0, "+", ""))

Note that if your field isn't actually a number yet you may need to cast it first (either in your dataset query, or using SSRS expressions).

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