Forum Discussion
DAX Function for 'Customers also bought'
- 9 years ago
Hi JosephJC
A Basket Analysis pattern will work for this.
http://www.daxpatterns.com/basket-analysis/
Here's a dummy example pbix
First create a 'Filter Product' table with an inactive relationship with your Orders table:
You use the 'Filter Product' table to select the product(s) to be analysed.
Then, assuming you have created your base measures for Quantity/Price etc, you create 'basket analysis' measures with this pattern (taken from DAX Patterns):
Order Quantity for Customers who bought Filter Product = CALCULATE ( [Order Quantity], CALCULATETABLE ( SUMMARIZE ( Orders, Orders[Customer] ), ALL ( Orders[Product] ), USERELATIONSHIP ( Orders[Product], 'Filter Product'[Filter Product] ) ) )This measure will return the Order Quantity for any Products purchased by Customers who purchased the products selected in 'Filter Product'.
Hopefully this or something similar meets your needs.
Cheers,
Owen
Hi OwenAuger
Thank you for the reply.
Right now when i select two products/items in the slicer, it will calculate separately the sum of the other items sold together (as shown below).
The Result I Wanted: If Selected Items are D & E (multiple products sold together to customers) , Data Will Show
D 21
E 2
F 24
G 14
Hope this makes sense. Thank you so much for your help.
Hi again, just got back to looking at this now.
It could be that either the measure or model needs to be adjusted.
What do you get if you remove the grouping by the outer Item in the visual (PivotTable)?
Could you post a simple table of data (similar to that behind your previous post) and expected result, just to confirm the required logic?