SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Basket Analysis in SSAS - Identifying orders where no other products were purchased


Basket Analysis in SSAS - Identifying orders where no other products were purchased

Author
Message
msifed
msifed
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 95
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search