SSRS 2008:如何基于另一个参数创建参数

发布于 2024-12-06 12:32:45 字数 2645 浏览 0 评论 0原文

我知道其他人也问过类似的问题,但我已经尝试过他们的解决方案,但它仍然对我不起作用。

我有一个名为“Region”的参数,它使用“region”数据集,另一个名为“Office”的报表参数使用“office”数据集。

现在我希望根据“区域”选择来过滤“Office”值列表。这是我到目前为止所做的。对于区域数据集,它返回“regions_id”和“region_description”。然后,对于“区域”报告参数,我选择了“文本”数据类型并允许空值。选择“文本”可能是错误的,因为这是一个唯一标识符值。对于可用值,我选择了区域数据集和regions_id作为值,region_description作为标签。我转到“高级”选项卡并选择“始终刷新”。在“默认”选项卡上,我输入“(空)”,以便他们想要查看所有区域。

接下来,我创建了一个名为“regions_id2”的报告参数,允许空值,并设置可用值=区域数据集。对于值和标签,我指定了regions_id。对于默认值,我再次输入“(Null)”。我再次选择“始终刷新”。

最后,我将这个“regions_id2”参数添加到“office”数据集中。然后,office 报告参数使用具有可用值的“office”数据集。值字段 =“group_profile_id”,标签字段 =“name_and_license”。默认值=“(空)”。高级“始终刷新”。

我以相同的顺序订购了这些报告参数:Regions、regions_id2 和 Office。但是现在,当我运行此报告时,我没有收到任何错误,但是,无论我为区域选择什么,办事处列表都包含所有办事处。以下是我针对这些数据集的 T-SQL:

CREATE Procedure [dbo].[rpt_rd_Lookup_Regions]
(
    @IncludeAllOption bit = 0,

)

As
SET NOCOUNT ON

If @IncludeAllOption = 1
BEGIN
    Select Distinct
    NULL AS [regions_id],
    '-All-' AS [region_description]

    UNION ALL
    SELECT Distinct
        [regions_id],
        [region_description]
    FROM [evolv_cs].[dbo].[regions]
    Where [region_description] not in ('NA','N/A')
    Order By [region_description]
END
Else
BEGIN
    SELECT Distinct
        [regions_id],
        [region_description]
    FROM [evolv_cs].[dbo].[regions]
    Where [region_description] not in ('NA','N/A')
    Order By [region_description]
END

CREATE  Procedure [dbo].[rpt_rd_Lookup_Facilities]
(
    @IncludeAllOption bit = 0,
    @regions_id uniqueidentifier = NULL
)

As
SET NOCOUNT ON

If @IncludeAllOption = 1
BEGIN
    Select
        Null As [group_profile_id],
        Null As [profile_name],
        Null As [license_number],
        Null As [other_id],
        --Null As [Regions_id],
        '-All-' As [name_and_license]
    UNION ALL
    SELECT
        [group_profile_id],
        [profile_name],
        [license_number],
        [other_id],
        --[regions_id],
        [profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
    FROM [evolv_cs].[dbo].[facility_view] With (NoLock) 
    Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
    Order By [profile_name]
END
Else
BEGIN
    SELECT
        [group_profile_id],
        [profile_name],
        [license_number],
        [other_id],
        [regions_id],
        [profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
    FROM [evolv_cs].[dbo].[facility_view] With (NoLock)
    Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
    Order By [profile_name]
END

我可能做错了什么?

I know others have asked similar questions, but I have tried their solutions and it still is not working for me.

I have one parameter called "Region" which uses the "region" dataset and another report parameter called "Office" which uses the "office" dataset.

Now I want "Office" list of values to filter based on "Region" selection. Here is what I did so far. For the region dataset, it returns "regions_id" and "region_description". Then for "Region" report parameter, I selected "Text" datatype and allow Null values. This may be a mistake to select "text" since this is a uniqueidentifier value. For available values, I selected the region dataset and regions_id for value, region_description for label. I went to Advanced tab and selected "Always refresh". And on Default tab, I entered "(Null)", for when they want to see all regions.

NExt, I created a report parameter called "regions_id2", allow null values, and I set available values = region dataset. For values and label both, I specified the regions_id. For default value, I again entered "(Null)". And I again selected "Always refresh".

Finally, I added this "regions_id2" parameter to the "office" dataset. And then the office report parameter uses the "office" dataset with available values. Value field = "group_profile_id" and label field = "name_and_license". Default values = "(Null)". Advanced "Always refresh".

And I ordered these report parameters in this same order: Regions, regions_id2, and Office. But now when I run this report I get no errors, however, the list of offices includes all of the offices regardless of what I choose for regions. Here is my T-SQL for these datasets:

CREATE Procedure [dbo].[rpt_rd_Lookup_Regions]
(
    @IncludeAllOption bit = 0,

)

As
SET NOCOUNT ON

If @IncludeAllOption = 1
BEGIN
    Select Distinct
    NULL AS [regions_id],
    '-All-' AS [region_description]

    UNION ALL
    SELECT Distinct
        [regions_id],
        [region_description]
    FROM [evolv_cs].[dbo].[regions]
    Where [region_description] not in ('NA','N/A')
    Order By [region_description]
END
Else
BEGIN
    SELECT Distinct
        [regions_id],
        [region_description]
    FROM [evolv_cs].[dbo].[regions]
    Where [region_description] not in ('NA','N/A')
    Order By [region_description]
END

CREATE  Procedure [dbo].[rpt_rd_Lookup_Facilities]
(
    @IncludeAllOption bit = 0,
    @regions_id uniqueidentifier = NULL
)

As
SET NOCOUNT ON

If @IncludeAllOption = 1
BEGIN
    Select
        Null As [group_profile_id],
        Null As [profile_name],
        Null As [license_number],
        Null As [other_id],
        --Null As [Regions_id],
        '-All-' As [name_and_license]
    UNION ALL
    SELECT
        [group_profile_id],
        [profile_name],
        [license_number],
        [other_id],
        --[regions_id],
        [profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
    FROM [evolv_cs].[dbo].[facility_view] With (NoLock) 
    Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
    Order By [profile_name]
END
Else
BEGIN
    SELECT
        [group_profile_id],
        [profile_name],
        [license_number],
        [other_id],
        [regions_id],
        [profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
    FROM [evolv_cs].[dbo].[facility_view] With (NoLock)
    Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
    Order By [profile_name]
END

What could I possibly be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熊抱啵儿 2024-12-13 12:32:45

我通过从 Office 数据集的区域数据集中选择区域参数值来修复此问题

I fixed this by selecting the region parameter value from region dataset for the office dataset

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文