Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Akshay
Regular Visitor

How to implement market basket analysis

We have customer details table with data like

 

OrderID     ProductName     Sales

1001          a, b                     $20

1002          a,c                      $20

1003          a,b                     $20

1004          a,c                      $20

1005          a,b                     $20

 

I need a Market Basket as when I select product A, it should display a list as:

Product     Orders

B               3

C               2

 This means, Product B is purchased 3 times with product A and similarly product C is purchased 2 times with product A.

I have a dashborad created in tableau. I need to create a replicate of it in powerbi.

Please follow this link: https://ibb.co/dquarv

 

2 REPLIES 2
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @Akshay,

There is no direct market basket analysis visual in Power BI desktop. But you can achieve your requirement by following the steps.

1. Right click the table->Query Editor, split the product name by selecting "split columns"->By Delimiter->comma shown in the screenshot. Then click apply on homw page.

1.PNG

Here is my query statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwMFRQ0lFK1EkCkkYGSrE6YEEjsFgyipgxFnUmWNSZoqiLBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [OrderID = _t, #" ProductName" = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"OrderID", Int64.Type}, {" ProductName", type text}, {"Sales", Int64.Type}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", " ProductName", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {" ProductName.1", " ProductName.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{" ProductName.1", type text}, {" ProductName.2", type text}})
in
    #"Changed Type1"


2. Create a slicer including ProductName.1, create a measure using the formula below. Then create a table visual to display the expected result.

Orders = COUNTA(Table1[ ProductName.2])

3.png

I upload my .pbix file as attachment, please download and review more details.

Best Regards,
Angelia

Thank you for the Post but There is no PBX file attached with this post , can you upload it?

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors