简体   繁体   English

SSRS如何在多个条件下计数?

[英]SSRS how to count with multiple conditions?

I'm new to expressions in SSRS, hope you can help! 我是SSRS表达式的新手,希望能为您提供帮助!

I need to create the following: 我需要创建以下内容:

"Count [issueID] where [closed] is not null and [due_date] is in the past." “计数[issueID],其中[closed]不为空,并且[due_date]过去。

I can do the first bit, but don't know the syntax to add the "...and [due_date] is in the past" in the textbox expression. 我可以先做一点,但不知道在文本框表达式中添加“ ...和[due_date]过去”的语法。

Cheers 干杯

Lins 林斯

It would be easier to modify your dataset source to return this flag in your data. 修改数据集源以在数据中返回此标志会更容易。 If you are not going to modify your data then I guess you could... 如果您不打算修改数据,那么我想您可以...

  1. Add a Calculated Field to your Data Set MyCalc. 将计算字段添加到您的数据集MyCalc。
  2. Set the expression for the Calculated Field 设置计算字段的表达式

    =IIF(!IsNothing(Fields!Closed.Value) && Fields!DueDate.Value < DateTime.Now,1,0) = IIF(!IsNothing(字段!Closed.Value)&&字段!DueDate.Value <DateTime.Now,1,0)

  3. Now you can add an expression similar to 现在您可以添加类似于以下内容的表达式

    =IIF(SUM(Fields!MyCal.Value) > 10 , "+10","not + 10") = IIF(SUM(Fields!MyCal.Value)> 10,“ +10”,“ not + 10”)

You can try this: 您可以尝试以下方法:

select 
count(case when [closed] is not null then [issueID] else 0 end) as 'TotalCount'
from [Your_Table]
where [due_date] <= getdate()

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

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