In this blog, I want to discuss how to create a Stacked bar chart with two measures and totals of the stack at the end. In my earlier blog, I showed how to display total on a stacked bar chart in Tableau. That stacked bar was created using only one measure and was relatively easy.

Creating Stacked Bar chart with two Measures

First we will create a stacked bar chart with two measures and then we will apply Totals to it. You can use Tableau Public or desktop for this exercise. 

  1. Connect to Sample-Super store.xls data set. Use the Orders table.
  2. From the data pane, place a dimension such as Order Date on the Rows. Place Measure Names on the Color.
  3. Right-click on the Measure Names on the Color and select Filter. On the Filter screen, select the measures which you want to include in your stack chart. I will choose Profit and Quantity.
Filter the Measure Names
Filter the Measure Names

4. From the data pane/Measures, place Measure Values on the Columns. This will create your Stack bar chart. 

5. Place Measure Values on the Label card. This will show you the numbers on the bar.

Stack chart with 2 measures
Stack chart with two measures

Creating Totals on the Stacked bar chart with two measures

Now we would like to add totals at the end of the bar so that the numbers of Profit and Quantity can add up to Totals.

  1. Create a calculated field. Navigate to menu Analysis and select Create Calculated Field. Name the calculated field as Total and use the following calculation:   

                                        Profit + Quantity 

2. Drop this Total calculated field next to Measure Values on Columns. This will show you two bar charts.

3. On Columns, right-click on Sum(Total) and select Dual Axis. Right-click on the axis and choose “Synchronize axis”.

4. Click on the Sum(Total) on the Columns again. Navigate to Marks and change the shape of Sum(Total) to circle.

Changing display to Circle
Changing the display of the second measure to Circle

This will give you a Stacked Bar chart with Totals at the end, depicted with a circle.

Stacked Bar Chart with multiple measures and Totals
Stacked Bar Chart with two measures and Totals


About the Author

Chandraish Sinha has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau,Power BI, and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Related posts

How to use Cycle Fields in Tableau?

How to use Cycle Fields in Tableau?

The Cycle field option is available in the Analysis menu and is used to cycle/rotate the dimension or measure fields in a visualization. In this blog, we will understand how to use Cycle Fields in Tableau.

What is the Cycle Fields option?

In Tableau, “Cycle Fields” refers to a feature that allows user to cycle through different dimensions or measures in a visualization without manually changing them. This feature is useful in analyzing the data from various perspectives quickly.

Using Cycle Fields in Tableau

To explain this concept, I will connect to Sample-Superstore.xls. If you are new to Tableau, learn how to connect to Excel data source.

  1. Create a bar chart by placing Sales on Columns, Category and Region on Rows. Place Segment on Color and finally Sales on Text (under Marks) to show the numbers on the bar as shown below:
Bar chart displaying Sales by Category, Region and Segment.

The above chart displays Sales by Category, Region and Segment. Notice the placement of the dimensions Category, Region and Segment.

  1. Now, navigate to Analysis menu and from the bottom, select Cycle Fields ( The second last option). As we make this selection, notice how the placement of fields change as shown below:
Bar chart grouped first by Category and then Segment.

After using the Cycle fields option, Region has moved to Color and Segment has moved to Rows.

  1. Use the Cycle Fields option again, this time you would notice dimension grouping or the order of dimensions on rows have changed and also Segment moved to color as shown below:
Bar chart grouped first by Region and then Category.
  1. Use the Cycle Fields option again and this time you would notice Region and Segment are on rows and Category has come on Color as shown below:
Bar chart with Region and Segment on rows and Category on color.

The advantage of using Cycle Field option is that Tableau is automatically changing the position of the fields with user doing it manually or by creating a seprate chart.

For more tips like these or to learn Tableau from beginners to advanced levels, checkout my book Dashboarding with Tableau.

Chandraish Sinha is the founder and President of Ohio Computer Academy, a company dedicated to providing IT education. An enthusiastic IT trainer, Chandraish embodies his company’s motto: Inspire, Educate & Evolve.

He has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau, Power BI and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in various domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Read More

Comparing Data Merging Techniques in Tableau

Comparing Data merging techniques in Tableau

There are various ways to combine or merge data in Tableau. Comparing data merging techniques in Tableau enables analysts to make informed decisions about which method to use in specific scenarios. This blog will explain various methods of merging data and when to use them.

In a visualization application like Tableau, merging of data consolidates information from multiple sources into a unified or single data set. This process enables users to design comprehensive visualizations that incorporate data from various sources. 

Data merging techniques

Tableau merges data by implementing the following methods:

  • Relationships: Tableau creates relationships by linking the tables through their common fields. Relationship do not create explicit joins but generate them dynamically when fields from the tables are utilized in visualization. Learn how to create relationships in Tableau.
Data merging using Relationship in Tableau
Two tables in a relationship
Data merging using joins in Tableau
Join between two tables and different join types in Tableau
  • Union: The union feature in Tableau enables users to vertically append tables to one another. It requires the table and field structure to be identical.
Data merging using Union between the tables
Union between two tables
  • Data Blending: Data blending is a process of combining data from different data sources based on a common dimension. It which works by keeping the data sources separate but combining them only at the time of creating a visualization.

Comparing Data merging techniques in Tableau

Various methods are employed to combine data in Tableau, but at times, it can be confusing to determine which method is suitable for a particular scenario. To decide on which data merging technique to use, follow the guidelines as mentioned below:

  • Utilize the relationships when the data in the tables display one-to-many or many-to-many cardinality, with varying levels of granularity.
  • Joins should be employed when the data in the tables exhibit one-to-one or many-to-one cardinality. Joins are useful when data across the entire workbook can be affected by the join condition.
  • Utilize union, when tables require vertical appending.
  • Data blending is employed when visualizations require fields from different data sources. Additionally, it is utlized when blending requirements vary from one sheet to another.

Learn more about Tableau functionality in the book Dashboarding with Tableau.


Chandraish Sinha is the founder and President of Ohio Computer Academy, a company dedicated to providing IT education. An enthusiastic IT trainer, Chandraish embodies his company’s motto: Inspire, Educate & Evolve.

He has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau, Power BI and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in various domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Read More

Image role in Tableau

Image role in Tableau

This blog will discuss Image role in Tableau. It is a new feature previously released in Tableau 2022.4 and later made available in Tableau server 2023.1.

Image role is used to add web images dynamically in the worksheet. It is assigned to the dimension fields that include URLs pointing to the web image.

The data for the image fields should meet the guidelines set by Tableau, to be assigned an image role. These guidelines are:

  • The URL should navigate to image files with extensions such as, .png, .jpeg or .jpg.
  • Each image URL must begin with http or https. If no protocol is included, Tableau adopts https.
  • 500 images per field can be loaded.
  • Each image file should be less than 128 kb.

Image role adds context to the data by displaying the associated image.

Image role in Tableau

To create this example, I have created an Excel file called SubCategory_Images.xls. It has the following format.

SubCategory_Images.xls

The excel file contains Sub-category, Image URL (url to the location of the image) and Sales.

Steps to Implement Image role in Tableau

  1. Launch Tableau desktop. Use Microsoft Excel as the connection type and connect to SubCategory_Images.xls.
  2. It will automatically connect to Subcategory_Images sheet as it contains only one sheet.
  3. Click on Sheet1 at the bottom of the screen to navigate to the Tableau development environment.
  4. From the data pane, click on URL and change the Image role to URL. This will change the data type/icon of URL to image.
Changing the Image role
  1. Create a visualization. Place Sub-Category and URL on Rows. Place Sales on Text (under Marks).

The resulting visualization will display images for each of the Sub-Category. These images are retrieved from the URLs specified in the excel file.

Sub-category with Images.

Image role will help in differentiating various products under the same category. For example, a company sells different types of chairs, and the images of these types such as office chair, living room chair etc. will provide more insight to the user.  


To become an expert in Tableau, refer to my latest book – Dashboarding with Tableau.

To practice Tableau, visit Tableau quiz and follow my blogs.


About the Author

Chandraish Sinha has  20+ years of experience in Information Technology. He is an accomplished author and has published 11 books covering Business Intelligence related topics such as, Tableau, Power BI and Qlik. Checkout his Amazon Author profile.

His latest book Excel Basics to Advanced covers all the aspects of MS Excel and provides exercises for self-learning.

Similarly, his recent book, Dashboarding with Tableau, covers all the features in Tableau and includes exercises for self-learning.

He has implemented IT solutions in different domains viz. Pharmaceutical, Healthcare, Telecom, Financial and Retail.

He blogs regularly on various IT topics. Check them out in the links given below: 

Blogs

Learn Tableau

Learn All Bi

Read More

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.