How to create a dynamic progress bar in Tableau

How to create a dynamic progress bar in Tableau


https://public.tableau.com/app/profile/zyad.wael/viz/Book1_17394652740800/Dashboard

1- Introduction

In this dashboard, I developed a custom progress bar in Tableau to visually represent profit performance against a target. The design inspiration for this dashboard widget comes from Nicholas Lea-Trengrouse , who has showcased innovative approaches to UI/UX within Power BI.

What makes this implementation unique is that it is built natively within Tableau, without relying on any third-party extensions.

The progress bar dynamically updates based on profit data, using calculated fields to maintain an intuitive and engaging design. In the following sections, I will break down the step-by-step process of constructing this custom progress bar, detailing the calculations, visualization techniques, and formatting tricks used to achieve this clean, professional look.

First, we'll create five separate sheets, each representing 20% of the progress bar. This division allows us to have more control over the visual representation and the logic behind each segment.


2- Creating Calculated Fields

Before we proceed with the visual design, we need to create some calculated fields that will help us shape the progress bar.

  • Bottom: This calculated field is needed to create the rounded shape at the bottom of the progress bar.

MIN(0)        

  • Top: Similarly, the "Top" calculated field is needed to create the rounded shape at the top of the progress bar.

MAX(1)        

  • Ratio: If your data doesn't already contain a ratio, you'll need to calculate it. In our case, we used the profit ratio, which was calculated as follows:

SUM(Profit) / [Profit Target]        

Each of the five sheets has a corresponding calculation that determines its fill status based on the Ratio. The logic is consistent across all sheets, with the only difference being the range of values each segment covers to evaluate the Ratio and assign one of three statuses:

  • "Full": The segment is fully filled.
  • "Target": The segment is partially filled (within the target range).
  • "Empty": The segment remains empty.

2.1.1. First Bar (0% - 20%)

  • If the Profit Ratio is greater than 20%, the first segment is marked as "Full". If the ratio is between 0% and 20%, it is marked as "Target". Otherwise, it is marked as "Empty".

IF [Profit Ratio] > 0.20 THEN "Full"
ELSEIF [Profit Ratio] >= 0.0 AND [Profit Ratio] <= 0.20 THEN "Target"
ELSE "Empty"
END        

2.1.2. Second Bar (20% - 40%)

  • If the Profit Ratio is greater than 40%, the second segment is marked as "Full". If the ratio is between 20% and 40%, it is marked as "Target". Otherwise, it is marked as "Empty".

IF [Profit Ratio] > 0.40 THEN "Full"
ELSEIF [Profit Ratio] >= 0.20 AND [Profit Ratio] <= 0.40 THEN "Target"
ELSE "Empty"
END        

2.1.3. Third Bar (40% - 60%)

  • If the Profit Ratio is greater than 60%, the third segment is marked as "Full". If the ratio is between 40% and 60%, it is marked as "Target". Otherwise, it is marked as "Empty".

IF [Profit Ratio] > 0.60 THEN "Full"
ELSEIF [Profit Ratio] >= 0.40 AND [Profit Ratio] <= 0.60 THEN "Target"
ELSE "Empty"
END        

2.1.4. Fourth Bar (60% - 80%)

  • If the Profit Ratio is greater than 80%, the fourth segment is marked as "Full". If the ratio is between 60% and 80%, it is marked as "Target". Otherwise, it is marked as "Empty".

IF [Profit Ratio] > 0.80 THEN "Full"
ELSEIF [Profit Ratio] >= 0.60 AND [Profit Ratio] <= 0.80 THEN "Target"
ELSE "Empty"
END        

2.1.5. Fifth Bar (80% - 100%)

  • If the Profit Ratio is greater than 100%, the fifth segment is marked as "Full". If the ratio is between 80% and 100%, it is marked as "Target". Otherwise, it is marked as "Empty".

IF [Profit Ratio] > 1.0 THEN "Full"
ELSEIF [Profit Ratio] >= 0.80 AND [Profit Ratio] <= 1.0 THEN "Target"
ELSE "Empty"
END        

For the progress bar to function correctly, the axis must be configured so that if the profit ratio is, for example, 15%, it falls within the first bar (0% to 20%), and the mark should be positioned in the middle of that bar. This normalization is crucial for accurately representing the progress and ensuring the visual is intuitive and user-friendly.

2.2.1. First Bar (0% - 20%)

The calculation determines the fill level for the progress bar. For example, a 15% ratio results in (0.15 - 0) / 0.20 = 0.75, meaning the progress bar is 75% filled.

([Profit Ratio] - 0) / (0.20 - 0)        

2.2.2. Second Bar (20% - 40%)

  • The calculation evaluates the fill level for the second progress bar. A 50% ratio results in (0.50 - 0.40) / 0.20 = 0.50, meaning 50% filled.

([Profit  Ratio] - 0.20) / (0.40 - 0.20)        

2.1.3. Third Bar (40% - 60%)

  • The calculation evaluates the fill level for the third progress bar. A 50% ratio results in (0.50 - 0.40) / 0.20 = 0.50, meaning 50% filled.

([Profit Ratio] - 0.40) / (0.60 - 0.40)        

2.1.4. Fourth Bar (60% - 80%)

  • The calculation determines the fill level for the fourth progress bar. A 70% ratio gives (0.70 - 0.60) / 0.20 = 0.50, indicating 50% filled.

([Profit Ratio] - 0.60) / (0.80 - 0.60)        

2.1.5. Fifth Bar (80% - 100%)

  • The calculation measures the fill level for the fifth progress bar. A 90% ratio results in (0.90 - 0.80) / 0.20 = 0.50, meaning 50% filled.

([Profit Ratio] - 0.80) / (1.0 - 0.80)        

3- Setting Up the Sheets

  • Start by creating five new sheets in Tableau. Each sheet will represent one segment of the progress bar.
  • In each sheet, drop the measure values to the Columns shelf. When you do this, you'll notice that the measure names are automatically dropped to the Detail Marks card and to the Filter shelf.
  • Right-click on the Measure Names in the Filters shelf and remove any unnecessary measures. In this case, keep only the calculated fields we just created: Top, Bottom, and Bar Ratio (the logic that normalizes the axis for each bar). The final selection should look like this:

Next, right-click on the secondary measure in the Columns shelf and select Dual Axis. After this, right-click on either of the axis headers and choose Synchronize Axis to align their scales accurately. Your visualization should now appear as shown below:

Ensure that the Measure Values are consistently arranged in the same order. Next, update the Measure Values in the Marks card by setting their Mark Type to Bars, while keeping Measure Values (2) as Circles.

In the All Marks card, adjust the Measure Values by moving them to the Color mark for better visualization. Then, navigate to the Analysis tab, select Stacked Bars, and turn it Off to separate the bars for better comparison.

Congratulations! You've successfully created the first progress bar! ?? Now, repeat the same process for the remaining four sheets. For testing purposes, I've also created a parameter and assigned it to the Calculated Ratio, allowing you to easily change the color and test different scenarios.


If you're feeling stuck while developing the progress bar, check out this quick demo, it’ll guide you through the process! Happy Vizzing ??


Mohanad Hany

junior data Analyst | SQL | PowerBI | python

6 天前

Very helpful and useful tips!

回复
Louis Yu

Tableau Visionary & Ambassador ? Co-Host of #GamesNightViz ? Co-Lead for SG Tableau User Group ? 7 x #VizOfTheDay ? Top 15 #IronViz qualifier 2023 ? Mentor/Instructor/Speaker

1 周

Simple and effective!

Nicholas Lea-Trengrouse

Power BI Disrupter | Head of Business Intelligence at Columbus (UK)

1 周

Thank you for the shoutout!

要查看或添加评论,请登录

Zyad Wael的更多文章

  • Tableau Desktop Time Savers

    Tableau Desktop Time Savers

    It’s incredibly refreshing to know that regardless of whether you have been using Tableau Desktop for years or months…

    5 条评论
  • Summary of Chapter 1

    Summary of Chapter 1

    The author focuses on Structured Query Language (SQL) technology as a tool for conducting data analysis. SQL, the…

    2 条评论

社区洞察

其他会员也浏览了