How to create a dynamic progress bar in Tableau
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.
MIN(0)
MAX(1)
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:
2.1.1. First Bar (0% - 20%)
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 [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 [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 [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 [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%)
([Profit Ratio] - 0.20) / (0.40 - 0.20)
2.1.3. Third Bar (40% - 60%)
([Profit Ratio] - 0.40) / (0.60 - 0.40)
2.1.4. Fourth Bar (60% - 80%)
([Profit Ratio] - 0.60) / (0.80 - 0.60)
2.1.5. Fifth Bar (80% - 100%)
([Profit Ratio] - 0.80) / (1.0 - 0.80)
3- Setting Up the Sheets
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 ??
junior data Analyst | SQL | PowerBI | python
6 天前Very helpful and useful tips!
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!
Power BI Disrupter | Head of Business Intelligence at Columbus (UK)
1 周Thank you for the shoutout!