I have set up an SSAS cube to allow our analysts to do some Basket Analysis type queries, for example if you choose a particular product it will tell you what other products were purchased in the same basket (percentage by product).
I achieved this using many to many relationships between multiple copies of the same order line level sales data, linked via an order level dimension.
Basically following the example below and tweaking it to fit our model
This is all working great and I have now enhanced it to allow 2 products to be chosen.
My remaining challenge is this - The analysts want to be able to report on the percentage of orders where no other products were purchased. In other words the percentage of orders where the chosen products were the only things in the basket.
I'm struggling to get my head around how to model this in MDX - Has anyone else come across this? And can anyone offer any advice please?
I'm considering replicating the problem in AdventureWorks so I can share the solution but just wondered generally if anyone had come across this before?
Theoretically I could use OrderItemQuantity as follows, my challenge is converting the following into MDX:At an order level - If total order item quantity minus (order item quantity for product A plus order item quantity for product B) equals zero then I know that this order only contained the selected products A and B.
The code below works when I view the numbers at order level but as soon as I aggregate at something higher than order level it falls apart.
CASE WHEN [Measures].[Order Item Quantity] = 0
CASE WHEN [Measures].[Order Item Quantity]
-[Measures].[Product A Quantity]
-[Measures].[Product B Quantity]
I'm sure there must be some MDX syntax or concept that I'm missing here - I need to force the cube to calculate this at order level and then aggregate the result rather than calculate it at the post aggregation level.