Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Basket Analysis in SSAS - Identifying orders where no other products were purchased Expand / Collapse
Author
Message
Posted Thursday, August 15, 2013 9:40 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 28, 2014 8:58 AM
Points: 3, Visits: 92
Hi All

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

http://www.codeproject.com/Articles/33765/Market-Basket-Analysis-in-SSAS-2005

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
THEN NULL
ELSE

CASE WHEN [Measures].[Order Item Quantity]
-[Measures].[Product A Quantity]
-[Measures].[Product B Quantity]
= 0
THEN 1
ELSE 0
END
END

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.

Many thanks

Dan
Post #1484827
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse