简体   繁体   English

在SSRS表达式中使用Count()和IIF

[英]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. 我试图计算“上一年度比较”大于0的值的数量。我在StackOverflow上找到了一些示例,但没有任何东西给我我想要的计数。

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. 此表达式计数0值。 Keep in mind that this expression has undergone several modifications. 请记住,此表达式已经过几次修改。 What am I missing? 我想念什么?

Your COUNT should be around your IIF . 您的COUNT应该在您的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. 什么都不是SSRS NULL,不计入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: 当然,如果Previous_Year_Comp是VARCHAR值而不是DECIMAL or INTEGER ,则可能需要这样的内容:

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

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

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