本文介绍了SSRS:我可以知道用户是否选择了“全部"?在多值参数中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户希望我重复报告页眉中的参数值.但如果他们只是在多值参数上选择全选",他们希望列出文本任何".

Customer wants me to repeat the parameter values in the page header of the report. But if they just choose "Select All" on a multi-valued parameter, they want the text "Any" listed.

例如,一个参数有一组固定的 9 个值.我将文本框的表达式硬编码为:

For example, one parameter has a fixed set of 9 values. I hard-coded the expression for a text box to:

="Room Size: " &
iif(Parameters!pRoomCap.Count=9,
    "Any",
    Join(Parameters!pRoomCap.Value, ", "))

如果参数源是未知大小的查询,我该怎么做?

How can I do this if the parameter source is a query of unknown size?

推荐答案

试试这个.您需要将数据集中的参数总数与所选参数的数量进行比较.以下假设您的多值参数使用名为dsRoomSizes"的数据集

Try this out. You need to compare the total number of parameters in the dataset to the count of selected parameters. The following assumes that your multivalue parameter is using a dataset called "dsRoomSizes"

="Room Size: "
& iif(Parameters!pRoomCap.Count = count(Fields!pRoomCap.Value,"dsRoomSizes"),
"Any",
Join(Parameters!pRoomCap.Value, ", "))

此表达式适用于页眉/页脚.

This expression will work in the page header/footer.

更新

为了找到解决您的问题的方法,以下内容应该适合您.感觉很黑,我鼓励你继续研究替代方法,但这会奏效:

In the interests of finding a solution to your problem, the following should work for you. It feels hackish and I encourage you to keep research alternative methods but this will work:

  1. 创建第二个多值参数并将其命名为pRoomCap_hidden".
    • 参数的来源是完全相同的查询
    • 在参数属性中,为同一个查询设置默认值
    • 重要:将参数可见性设置为隐藏
  1. Create a second multivalue parameter and name it something like "pRoomCap_hidden".
    • The source of the parameter is the exact same query
    • In the parameter properties, setting the default values to the same query
    • Important: Set the parameter visibility to hidden

这将在您的报告中创建第二个多值参数,该参数与您的初始多值参数完全相同,只是该参数列表将默认选择所有值.

This will create a second multivalue parameter in your report that is exactly the same as your initial multivalue parameter only this parameter list will have all values selected by default.

在标题的文本框中输入以下表达式:

Enter the following expression in a textbox in your header:

=IIF(Parameters!pRoomCap.Count = Parameters!pRoomCap_hidden.Count,"All",Join(Parameters!ReportParameter1.Value,", "))

以上将比较每个参数列表中的选定值.如果列表包含相同的选定值,则表示已在第一个列表中选择了全部".

The above will compare the selected values in each parameter list. If the lists contain the same selected values then that indicates that "All" have been selected in the first list.

就像我说的那样,它很hackish,但它绝对有效.在您升级到 2008 之前,这对您来说可能不是一个糟糕的解决方法.

Like I said, it is hackish but it definitely works. Until you are upgraded to 2008, this might not be a bad workaround for you.

这篇关于SSRS:我可以知道用户是否选择了“全部"?在多值参数中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 12:22
查看更多