Home Forums SQL Server 2005 Business Intelligence Add custom attribute so that I can measure the orders that contain a list of products but does not contain another list of products RE: Add custom attribute so that I can measure the orders that contain a list of products but does not contain another list of products

  • You should be able to craft the query to produce the result you want using a sub-cube/sub-query for the FROM clause (see example below). *How* you do this is really up to you, it's possible you could achieve this using Reporting Services with 2 multi-select parameter lists (though you really need to add some code to check for the instance where the user has selected no items from either or both lists).

    SELECT NON EMPTY [Orders].[OrderID].[OrderID].MEMBERS ON 1, NON EMPTY [Measures].[SalesAmount] ON 0

    FROM

    ( SELECT FILTER([Orders].[OrderID].[OrderID].MEMBERS, IsEmpty( ([Products].[Product].&[1], [Measures].[SalesAmount]))) ON 0 FROM [myCube])

    WHERE {[Products].[Product].&[10],[Products].[Product].&[9]}

    A brief explanation on the code:

    - the sub select is using a filter statement to reduce the orders to only those where there *was not* a product '1'.

    this sets a context for the outer query.

    - the main select clause simply selects the orders on rows and a measure on cols

    - the main select has a where clause that will filter the (already filtered) orders to only those that included '10' and '9'.

    HTH,

    Steve.

    Steve.