简体   繁体   中英

Using Count() and IIF in SSRS expression

I am attempting to count the number of values where the Previous Year Comp is greater than 0. I found examples on StackOverflow but nothing is giving me the count I want.

I have the following expression:

= IIF((Fields!Previous_Year_Comp.Value) > "0.00",
      count(Fields!Previous_Year_Comp.Value),0)

This expression is counting the 0 values. Keep in mind that this expression has undergone several modifications. What am I missing?

Your COUNT should be around your IIF .

=COUNT(IIF(Fields!Previous_Year_Comp.Value > "0.00", Fields!Previous_Year_Comp.Value, NOTHING)

NOTHING is SSRSs NULL that isn't counted with COUNT.

You are comparing a string to an integer value. Try this:

=IIF(Fields!Previous_Year_Comp.Value > 0, count(Fields!Previous_Year_Comp.Value),0)

Of course, if Previous_Year_Comp is a VARCHAR value and not a DECIMAL or INTEGER , you may need something like this:

=IIF(Fields!Previous_Year_Comp.Value <> "0.00", count(Fields!Previous_Year_Comp.Value),0)

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