开发者

SSRS 2008: How to create parameter based on another parameter

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜