连接 Reporting Services 中字段的不同行值

连接 Reporting Services 中字段的不同行值

问题描述:

我在 Reporting Services 中有一份报告,我想连接以逗号分隔的列的所有不同值,并将该值放入文本框中.我知道我可以使用以下答案之一在 SQL 中做到这一点 此处.但如果可能的话,我宁愿不更改 sql,而是在报告中进行更改.

I have a report in reporting services and I want to concatenate all the distinct values of a column separating by commas and place the value in a textbox. I know I could do it in the SQL using one of the answers here. But I'd rather not change the sql and just do it in the report if possible.

示例:我有一个包含多个字段的数据集,其中之一是类别.假设值是电话"、服务"、电话"、附件"、案例"、案例".我希望报告中的文本框以值附件、保护套、电话"结尾.

Example: I've got a dataset with several fields, one of which is category. Say the values are "Phone", "Service", "Phone", "Accessory", "Case", "Case". I want the textbox in my report to end up with the value "Accessory, Case, Phone".

以防万一,它是 SSRS 2008 R2.

In case it makes a difference, it is SSRS 2008 R2.

我想出了一个方法,虽然不是最优雅的解决方案.我添加了一个内部参数来获取所有可能类别的列表以及一个附加参数来消除重复项.我已经按照步骤 这里(从他们添加虚拟参数的部分开始)执行上述操作.

I've figured out a way, although not the most elegant solution. I've added an internal parameter to get the list of all possible categories as well as an additional parameter to get rid of the duplicates. I've followed the steps here (starting at the part where they are adding dummy parameters) to do the above.

本质上,

  1. 使用我想要的数据集和字段创建一个多值参数可用/选定值.请务必在常规标签.
  2. 添加 链接 到代码选项卡在报告属性中
  3. 创建第二个使用 RemoveDuplicates 的多值参数功能.同样,请务必标记为内部.
  1. Create a mulit-value parameter using the dataset and field I want for available/selected values. Be sure to mark as internal on the General tab.
  2. Add the RemoveDuplicates function shown in the link to the Code tab in Report Properties
  3. Create a second multi-value parameter that uses the RemoveDuplicates function. Similarly, be sure to mark as internal.

之后我在第二个参数上使用了 Join 函数来创建逗号分隔的列表.

After that I used the Join function on the second parameter to create the comma delimited list.