Posted By velan | 4 August, 2020

4 August: Boost Your Sales with Market Basket Analysis in Tableau

Market basket analysis is a data mining technique that helps to understand how customers buy products by identifying which items are frequently purchased together. Using Tableau helps us make useful visuals from the data to learn more about what customers buy. Here’s a comprehensive guide on performing Market Basket Analysis in Tableau, synthesizing insights from several leading sources.

What is Market Basket Analysis?

Market Basket Analysis is a technique that businesses use to determine which items customers buy together. Retailers can decide which items are frequently purchased together by analyzing what previous customers have purchased. This helps them decide where to put things in the store, which advertisements to run, and how to recommend additional items to buy.

The Purpose of Market Basket Analysis

The primary goal of Market Basket Analysis is to understand customer purchasing behavior and optimize business strategies accordingly. By delving into the associations between products, businesses can:

  • Optimize Product Placement: Arrange complementary items in close proximity to encourage additional purchases.
  • Enhance Cross-Selling and Upselling: Recommend relevant products based on customers’ current purchases, thereby increasing average order value.
  • Improve Inventory Management: Predict demand for certain products and manage stock levels efficiently to avoid shortages or overstock situations.
  • Personalize Marketing Strategies: Tailor promotions and marketing campaigns to individual customer preferences, leading to higher engagement and conversion rates.

Types of Market Basket Analysis

Types of Market Basket Analysis

Understanding what customers buy together is crucial for stores to improve their sales strategies. Let’s explore three different ways stores analyze this:

Descriptive Market Basket Analysis

This method dives into past sales records to find patterns in what customers typically purchase together. By spotting these patterns, stores can arrange related products nearby, making it more convenient for customers and increasing sales.

Predictive Market Basket Analysis

Instead of focusing solely on historical information, this approach utilizes previous sales data to forecast potential future purchases by customers. By carrying out this practice, stores can prepare in advance and recommend products that customers are likely to desire, simplifying the shopping experience and increasing revenue.

Differential Market Basket Analysis

This kind of analysis looks at the purchasing behavior of various customer segments. Stores can customize their products to meet the distinct needs of each group by grasping these differences, thus ensuring they offer desired items to customers.

Benefits of Market Basket Analysis

Implementing Market Basket Analysis offers numerous benefits to businesses:

  • Increased Revenue: By strategically bundling or recommending products, businesses can boost sales and revenue.
  • Enhanced Customer Satisfaction: Providing customers with personalized recommendations enhances their shopping experience and fosters loyalty.
  • Cost Efficiency: Targeted marketing efforts and optimized inventory management reduce unnecessary expenses and maximize profitability.
  • Competitive Edge: Understanding customer behavior gives businesses a competitive advantage in the market, enabling them to stay ahead of the competition.

Benefits of Market Basket Analysis

A Practical Market Basket Analysis Example

To illustrate how Market Basket Analysis works, let’s consider a simple example using a small dataset of transactions from a grocery store.

Example Dataset

Market Basket Analysis Example

Step-by-Step Market Basket Analysis

Identify Itemsets:

We start by identifying itemsets from the transactions. For simplicity, we’ll consider itemsets of up to two items.

Calculate Support:

Support for an itemset is calculated as the number of transactions containing the itemset divided by the total number of transactions.

  • Support(Bread) = 4/5 = 0.80
  • Support(Milk) = 4/5 = 0.80
  • Support(Bread, Milk) = 3/5 = 0.60

Calculate Confidence:

Confidence for a rule is the support of the itemset containing both items divided by the support of the item on the left side of the rule.

  • Confidence(Bread → Milk) = Support(Bread, Milk) / Support(Bread) = 0.60 / 0.80 = 0.75

Calculate Lift:

Lift is calculated as the confidence divided by the support of the item on the right side of the rule.

  • Lift(Bread → Milk) = Confidence(Bread → Milk) / Support(Milk) = 0.75 / 0.80 = 0.9375

In this example, the support of 0.60 for the itemset {Bread, Milk} means that 60% of the transactions include both Bread and Milk. The confidence of 0.75 for the rule {Bread → Milk} indicates that 75% of the transactions that include Bread also include Milk. The lift value of 0.9375 suggests that Bread and Milk are bought together slightly less frequently than would be expected if they were independent.

Algorithms for Market Basket Analysis

Several algorithms are commonly used for Market Basket Analysis:

Apriori Algorithm:

A classic algorithm that generates association rules based on itemsets and support thresholds. The Apriori algorithm uses a breadth-first search method to find frequent itemsets in transaction data.

FP-Growth Algorithm:

An efficient algorithm that discovers frequent itemsets using a tree structure known as the FP-tree. The FP-Growth algorithm accelerates processing time by constructing an FP-tree to condense transaction data, eliminating the necessity for generating candidates.

Eclat Algorithm:

Similar to the Apriori algorithm, the Eclat algorithm discovers frequent itemsets in the transaction data. However, the Eclat algorithm employs a vertical data structure that displays transactions as a list of items along with their respective transaction identifiers in order to enhance efficiency.

Steps to Conduct Market Basket Analysis in Tableau

1. Data Preparation

Start by loading your transaction data into Tableau. Ensure your dataset includes transaction IDs and product details. For a more robust analysis, you might want to include additional fields like customer ID, date of purchase, and product categories.

2. Creating a Self-Join

Perform a self-join on the transaction data using the transaction ID as the key. This join pairs each product in a transaction with every other product in the same transaction, creating combinations of items bought together. This step is crucial for generating the item pairs needed for the analysis.

3. Building the Analysis

Basic Visualization:

  1. Drag the product category (or sub-category) from the original dataset to the Rows shelf.
  2. Drag the product category (or sub-category) from the self-joined dataset to the Columns shelf.
  3. Change the Marks type to Square for a better visual representation of the data.
  4. Drag the transaction ID to the Text shelf and choose Count (Distinct) to show the number of transactions for each product pair.
  5. Drag the transaction ID to the Color shelf to visually differentiate between the frequencies of transactions.

Advanced Metrics:

To gain deeper insights, calculate metrics like Support, Confidence, and Lift:

  • Support: Probability that two products are bought together.
  • Confidence: Likelihood that a product is bought given that another product has already been bought.
  • Lift: Measure how much more likely it is that the second product is bought when the first product is bought compared to its general purchase rate.
Create calculated fields for these metrics using the following formulas:
  • Total Orders:{COUNTD([Transaction ID])}
  • Antecedent Occurrences:{FIXED [Product A]: COUNTD([Transaction ID])}
  • Consequent Occurrences:{FIXED [Product B]: COUNTD([Transaction ID])}
  • Combined Occurrences:{FIXED [Product A], [Product B]: COUNTD([Transaction ID])}
  • Support:[Combined Occurrences] / [Total Orders]
  • Confidence:[Support] / ([Antecedent Occurrences] / [Total Orders])
  • Lift:[Confidence] / ([Consequent Occurrences] / [Total Orders])

4. Visualizing the Results

Once you have calculated these metrics, you can create more insightful visualizations:

  • Heatmaps: Use Lift or Confidence on the Color shelf to create a heatmap that shows the strength of relationships between products.
  • Tables: Display Support, Confidence, and Lift in a table format to easily sort and identify the strongest associations.

5. Refining the Analysis

To refine your analysis:

  • Exclude null values and single product transactions to focus on meaningful pairs.
  • Use filters to analyze specific product categories or time periods.
  • Experiment with different visualization types to best communicate your findings.

Applications and Benefits

Using Market Basket Analysis in Tableau, stores can better understand how customers buy things. This helps them decide where to place items in the store, what sales to run, and what to recommend to customers. This increases sales for the retailer and improves the shopping experience for customers.

Examples of Market Basket Analysis

Let’s examine some instances to demonstrate the idea of Market Basket Analysis:

Grocery Stores:

Market Basket Analysis uncovers connections between frequently bought products, like bread and milk or chips and salsa. Grocery stores can enhance sales by recognizing these patterns and strategically placing products while creating specific promotions.

E-commerce Platforms:

E-commerce platforms commonly use Market Basket Analysis to suggest related products to customers by analyzing their browsing and purchase history. For instance, when buying a smartphone, a customer might receive suggestions for accessories like cases, screen protectors, or headphones.

Fast-Food Chains:

Market Basket Analysis enables fast-food chains to create combo meals or promotions by analyzing popular item pairings. For example, a burger consumer could have the opportunity to include fries and a drink for a lower cost, ultimately raising the total value of their purchase.

Let us go through the setup of a simple Market Basket Analysis in Tableau.

– Let us assume that we have a database of a grocery store with all relevant data like orders, categories, returns, products, etc.,

– The order has associated data like order ID and order date while the product has relevant data like category and sub-category

– Go to the data source and do a self-join with orders based upon the order ID.

– We will do the market analysis on categories and you can choose any relationship between them for the time being

– Now move to the sheets drag the category from products and drop it on columns

– Then drag the category from self-join and drop it on rows

– Now drag the order ID from Order to the text box on Marks.

– Then ensure that the count of the order ID is displayed by selecting count from the measure dropdown

– Drag the order ID tag and drop it on color to have a finer view of the analyzed data. You can also change the shape of the view based on convenience

– You can also have a simpler view by changing the relationship we fixed on the join tab

Thus, you have a comprehensive picture of the correlation between different products that the retailers can use to their advantage.

Thus, gain powerful insights about customer behavior using this technique to accelerate revenue generation with optimum effort.


Market Basket Analysis in Tableau is a powerful combo that helps businesses gain important insights from their data. Tableau’s visualization capabilities make these insights more accessible and actionable, resulting in better decision-making and strategic growth.

We are Business Intelligence & Data Analytics Service Consultants Reach us at +1 727 756 1632 or 

Post Comments

No Comments

Recent Posts

Predictive Analytics: Using Past Data To Predict Future Insights...

12 April, 2021

Top 4 Business Analytics Techniques By Vuelitics
Essential Business Analysis Techniques: A Comprehensive Guide...

18 January, 2021

Redefine Business Success Through Business Intelligence Technologies Blog By Vuelitics
Redefine Business Success Through Business Intelligence Technologies...

18 January, 2021

Leave Comment

Business Intelligence on your mind?