Search code examples
filtermdxparentmondrian

Mondrian - Parent with filtered children


I want to create a topcount of users per product category. My product dimension is like the following [Product].[ProductCategory].[ProductType] Users of my application can filter the products and it return a set like this: [Product].[ProductCategory1].[ProductType1], [Product].[ProductCategory3].[ProductType5], ...

Now I got the topcount per product category, but it doesn't filter the children of the category: the types. Example of my query:

SELECT
  NON EMPTY {[Measures].[Orders]} ON COLUMNS, 
  NON EMPTY 
    {Order(
       Generate(
         Exists(
           [Product].[ProductCategory].Members
          ,{
            [Product].[ProductCategory1].[ProductType1]
           ,[Product].[ProductCategory3].[ProductType5]
           }
         )
      , TopCount(
         Crossjoin(
           {[Product].[ProductCategory].currentmember}
          ,{[USER].[UserName].Members}
         )
        ,5.0
        ,[Measures].[Orders]
       )
     )
   , [Measures].[Orders]
   , DESC
  )
  } ON ROWS 
FROM [Products]

The [Product].[ProductCategory].currentmember doesn't return the category with filtered product types.

Does anyone have a solution?


Solution

  • I fixed my problem using a calculated measure to filter the measure with the product members.

    WITH MEMBER [Measures].[FilteredOrders] AS
    'SUM(exists([Product].[ProductCategory].currentmember.children, {[Product].[ProductCategory1].[ProductType1]
           ,[Product].[ProductCategory3].[ProductType5]}), [Measures].[Orders])'