Skip to content

Basket Analysis – No. of Customers who bought an initial basket of products, which also overlaps with another basket of products

>> Download the sample (Power BI)

This sample shows:

(i) The number of customers that bought an initial basket of products, where the products also overlap with another basket of products.

Initial Basket Customers =
CALCULATE (
[No. of Distinct Customers],
TREATAS ( VALUES ( 'Initial Basket'[Products] ), Sales_Table[Product] )
)
No. of Distinct Customers =
DISTINCTCOUNT ( Sales_Table[Customer] )
Selection Basket Customers =
CALCULATE (
[No. of Distinct Customers],
TREATAS ( VALUES ( 'Selection Basket'[Products] ), Sales_Table[Product] )
)
Total Basket Customers =
VAR InitialBasket =
CALCULATETABLE (
VALUES ( Sales_Table[Customer] ),
TREATAS ( VALUES ( 'Initial Basket'[Products] ), Sales_Table[Product] )
)
VAR SelectedBasket =
CALCULATETABLE (
VALUES ( Sales_Table[Customer] ),
TREATAS ( VALUES ( 'Selection Basket'[Products] ), Sales_Table[Product] )
)
RETURN
COUNTROWS ( INTERSECT ( InitialBasket, SelectedBasket ) )
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)