简体   繁体   English

SSRS 多值参数计数表达式

[英]SSRS Multi Value Parameter Count Expression

I am trying to count the number of records through a count expression in a text box based on the multi value parameters that are chosen.我正在尝试根据选择的多值参数通过文本框中的计数表达式来计算记录数。

My table:我的桌子:

WSVLWOs

WO_NUMBER    WO_ACTN_TY
18-003759   Adjust to Grade
18-005909   Repair / Replace Box
18-002559   Repair / Replace Box
18-003229   Inspection
18-003224   Repair / Replace Box

My count expression:我的计数表达式:

=Count(Fields!WO_NUMBER.Value, "WSVLWOs")

My Available Parameters我的可用参数

Adjust to Grade
Repair / Replace Box
Inspection

The filter on the table:桌子上的过滤器:

在此处输入图像描述

Now when I select multiple parameters, it does not seem to give me the sum of the count of the parameter values, only one of the parameter value.现在当我 select 多个参数时,它似乎没有给我参数值的计数总和,只有一个参数值。 Is the issue in my count expression?问题出在我的计数表达式中吗?

Your filter expression is您的过滤器表达式是

=Parameters!Tasks.Value(0) which is only the first selected parameter value.

There are a few ways to fix this issue.有几种方法可以解决此问题。

You should be able to change your expression to =JOIN(Parameters.Tasks,Value, ",") although this might not work depending on datatypes etc. All this does is pass a comma separated list to the filter.您应该能够将您的表达式更改为=JOIN(Parameters.Tasks,Value, ",")尽管这可能无法根据数据类型等进行。所有这些都是将逗号分隔的列表传递给过滤器。

However I would question if this is the best approach.但是,我会质疑这是否是最好的方法。 If you can, I would filter in the dataset query as this means only the required data is returned and it makes you count much simpler.如果可以的话,我会在数据集查询中进行过滤,因为这意味着只返回所需的数据,这让你计算起来更加简单。

If you need the individual records but also need the count then return all required rows with a dataset query that looks something like.如果您需要单独的记录但也需要计数,则返回所有必需的行,并使用看起来像这样的数据集查询。

SELECT * FROM WSVLWOs WHERE WO_ACTN_TY IN(@Tasks)

@Tasks will be passed into the query, parsed correctly and you will only get the records you need. @Tasks将被传递到查询中,正确解析,您只会获得所需的记录。 Your COUNT() expression with then work fine.您的COUNT()表达式与 then 工作正常。

If you only needed the count then then you could just do this in your dataset query and return just the count如果您需要计数,那么您可以在数据集查询中执行此操作并仅返回计数

SELECT COUNT(*) as myCount FROM WSVLWOs WHERE WO_ACTN_TY IN(@Tasks)

Then you could just reference the myCount fields from the dataset to get your answer.然后你可以从数据集中引用myCount字段来得到你的答案。

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

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