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 is the table of contents. Feel free to jump to any section that interests 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, and 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.
Boost your software development with nearshore teams
BairesDev provides end-to-end software outsourcing extending your in-house capacity and expertise, from definition and design, to development and testing.
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:
Select the Global Superstore dataset when the file prompt appears:
Set the Dataview Parameters
2.- Go to the dataset tab, select the “Orders” table and drag it to the data area.
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.
4.- Add the Product Subcategory as a relationship field.
5.- Set the join parameter of Order ID as equal. Afterward, set the join parameter of Product Subcategory as not equal.
6.- Go to the first worksheet (rename it as you prefer).
Create Tableau Data Visualization
7.- Drag and drop the Orders table’s Product Subcategory field on the worksheet’s 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.
9.- Drag the Order ID field into “Text.” Set it as a Count measure.
10.- Take another copy of Order ID, drag into “Color,” and set it as a measure.
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 order values.
Besides, the higher values and color intensities represent the product subcategory correlations that occur with greater frequency. Furthermore, high color intensity could mean you could define a strong association rule between the items.
11.- As a final touch, exclude the null category row, as these are orders in which all products are from a single category.
12.- Change view type to “Entire View”.
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 which product categories customers purchase 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.