MDX SSRS Parameter category chooses all sub category

家住魔仙堡 提交于 2019-12-02 07:04:22

As I said in comments you cannot use the Name of your member to slice your cube in MDX, you have to use the unique name instead. You have to handle it so when your user selects Category X and Category Y for your ParamCategory parameter, it should be set to [Service].[Category].&[Category X] and [Service].[Category].&[Category Y]. This is what I'd do.

I'd use an MDX script that returns label (Name) and unique name for populate Category.

WITH MEMBER [Measures].[Category Label] AS
  [Service].[Category].CurrentMember.Name
MEMBER [Measures].[Category UniqueName] AS
  [Service].[Category].CurrentMember.UniqueName
SELECT
{ [Measures].[Category Label], [Measures].[Category UniqueName] } ON COLUMNS,
{} ON ROWS
FROM [Sales-Cube]

In parameter properties / available values you have to use Category Label field for Label field and Category UniqueName for Value field.

The same apprach to populate ParamSubcategory.

WITH MEMBER [Measures].[SubCategory Label] AS
  [Service].[SubCategory].CurrentMember.Name
MEMBER [Measures].[SubCategory UniqueName] AS
  [Service].[SubCategory].CurrentMember.UniqueName
SELECT
{ [Measures].[SubCategory Label], [Measures].[SubCategory UniqueName] } ON COLUMNS,
{ [Service].[SubCategory].[SubCategory] } ON ROWS
FROM [Sales-Cube]
WHERE ( StrToSet ( @ParamCategory ) )

Note I am using ParamCategory to populate the ParamSubcategory only with the related subcategories.

Now you can use those parameters in your MDX script:

SELECT NON EMPTY { [Measures].[Sales Count] } ON COLUMNS,
NON EMPTY
{
  ( [Date].[Fiscal Year].[Fiscal Year].AllMembers )
} Dimension Properties MEMBER_CAPTION,
MEMBER_UNIQUE_NAME ON ROWS
FROM (
  SELECT ( STRTOSET( @ParamSubcategory ) ) ON COLUMNS
  FROM (
    SELECT ( STRTOSET ( @ParamCategory ) ) ON COLUMNS
    FROM [Sales-Cube]
  )
) CELL Properties Value,
BACK_COLOR,
FORE_COLOR,
FORMATTED_VALUE,
FORMAT_STRING,
FONT_NAME,
FONT_SIZE,
FONT_FLAGS

Note Filter and InStr function are not requerid since you are passing the unique name members.

It is not tested but should work, good luck!

Let me know if this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!