Market Basket Analysis in Tableau
Market Basket Analysis

How to Conduct a Market Basket Analysis in Tableau

Understanding their customers’ purchasing behaviors is critical to retailers. To this end, Market Basket Analysis is a preferred technique to uncover products purchased in bundles. This post shows an example of how to build a simple Market Basket Analysis in Tableau.

Tableau is a relatively new business intelligence tool and has quickly acquired a sizable market. Also, most businesses recognize Tableau for its easy-to-build data visualizations. Nevertheless, our model showcases its data correlation capabilities.

Here’s is the table of contents. Feel free to jump to any section that interest you:

What Is Market Basket Analysis?

Market basket analysis is the process behind amazon’s “customers who bought this also bought” feature. It is also contributory to the recommendation engines of online streaming services such as Netflix, Spotify, amazon prime video, amazon music, and many others.

In this post, we focus on an example of market basket analysis in Tableau. Likewise, for a more in-depth look at what market basket analysis is, its uses, how to perform and implement it in your organization, check out our blog post: What Is Market Basket Analysis and How It Can Increase Your Sales.

Market Basket Analysis helps inform better decisions around: 

  • Strategically placing products around physical stores.
  • Planning marketing promotions around products that drive sales of other products.
  • Recommending products to customers in real-time, where there is a high probability of making additional sales.

Initial Considerations

We used Tableau Public, which is a free version of Tableau available online.

If you plan to use tableau public, consider that any work you save becomes publicly available online. Hence, do not use tableau public if you don’t intend to make your dataset and dashboards available to everyone. Moreover, you can enroll in Tableau Public and download the app at the Tableau Public website.

If you own a trial or paid Tableau license, you can use it too, the procedure is the same and your data will remain private.

For this exercise, we use the global superstore tableau sample dataset. You can get the dataset here.

Market Basket Analysis Using Tableau

Following is the procedure to create a Market Basket Analysis in Tableau:

1.- Open Tableau and connect to the Global Superstore Tableau Dataset:

Market Basket Analysis in Tableau Step 1.1 Connect to Dataset

Select the Global Superstore dataset when the file prompt appears:

Step 1.2 Connect to Dataset Select File

Set the Dataview Parameters

2.- Go to the dataset tab, select the “Orders” table and drag it to the data area.

Market Basket Analysis in Tableau Step 2.1 Drag Orders table to the data area

Step 2.2 Drag Orders table to the data area Orders dataset

The Superstore Dataset contains a list of sample purchase details. Firstly, each line of the dataset includes the bought product, quantity and amount. Secondly, each line has its corresponding Order ID. Furthermore, each Order ID represents a different purchase or a Market Basket.

If two different product categories appear at the same Order ID, they correspond to two products purchased in a bundle.

3.- Do a self-join on the Orders table by dragging a second instance of the orders table to the data are. Then, select Order ID as the first relationship field.

Step 3 Orders table Self Join Order ID field

4.- Add the Product Subcategory as a relationship field.

Market Basket Analysis in Tableau Step 4.1 Add Product Subcategory

Step 4.2 Add Product Subcategory

Step 4.3 Add Product Subcategory

5.- Set the join parameter of Order ID as equal. Afterward, set the join parameter of Product Subcategory as not equal.

Step 5 Set Subcategory relationship parameter as not equal

6.- Go to the first worksheet (rename it as you prefer).

Step 6.1 Click and rename the first worksheet

Step 6.2 Go to the worksheet

Create Tableau Data Visualization

7.- Drag and drop the Orders table’s Product Subcategory field on the worksheet’s columns.

Market Basket Analysis in Tableau Step 7.1 drag and drop sub category on worksheets columns

Step 7.2 drag and drop sub category on worksheets columns

8.- Drag and drop the “Orders1” table Subcategory on the worksheet’s rows. To clarify, Orders1 is an additional instance of Orders resulting from the self-join.

Step 8.1 drag and drop sub category from self join orders on worksheets rows

Step 8.2 drag and drop sub category from self join orders on worksheets rows

9.- Drag the Order ID field into “Text.” Set it as a Count measure.

Market Basket Analysis in Tableau Step 9.1 Set Order ID as a Count measure

Step 9.2 Set Order ID as a Count measure

10.- Take another copy of Order ID, drag into “Color,” and set it as a measure.

Step 10.1 Drag another instance of Order ID to Color

Step 10.2 Set new Order ID measure to Count Distinct

Step 10.3 Change visualization to Square

You will now have two measures, one with the number of orders of each product category combination and another with colors of varied intensities representing a higher or lower number of orders values.

Besides, the higher values and color intensities represent the product subcategory correlations that occur with greater frequency.

11.- As a final touch, exclude the null category row, as these are orders in which all products are from a single category.

Market-Basket-Analysis-in-Tableau-Step 11 - exclude the null category row

12.- Change view type to “Entire View”.

Step 12.1 Change View to Entire View

Step 12.2 Entire View Market Basket Analysis

Tableau Market Basket Analysis on Video

Anthony Smoak’s YouTube channel features a handy video on building a market basket analysis using Tableau. Furthermore, it was the primary reference we used to develop our example.

Here we share the video:

Anthony Smoak is an expert in Tableau, Power BI, Qlikview, Python and SQL. Check out his website.

Uncover Your Customer’s Behaviors

This example demonstrated how to quickly analyze product categories’ correlation in the same purchase basket using Tableau. Firstly, we showed how to get data into Tableau and match products in the same basket. Secondly, we described how to set a visualization to identify the categories customers bought together more often.

Knowing with product categories customers purchases in bundles is useful to inform product placement, both physical and online, and to guide further analysis of specific products.

Now that you know how to create a market basket analysis in Tableau, we invite you to take action. Therefore, start exploring how market basket analysis can help you increase your sales and take your business to the next level.

Could your organization benefit from a recommender system? What are your thoughts on market basket analysis in Tableau? Leave a comment below.

Subscribe To Our List

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. You also acknowledge that you would like to hear from Tech Business Guide via emails. You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

Follow us on social media:

Leave a Reply

Your email address will not be published. Required fields are marked *