How to create a 100% stacked bar chart in Power BI: step by step
Let's build a 100% stacked bar chart in Power BI to compare the relative contribution of categories within each group. This visual is useful to show proportions (percentages) by group without losing sight of the total.
Prerequisites
- Power BI Desktop (updated version).
- A fact table with at least: Group, Category and Value.
- Basic knowledge of DAX and the Visualizations pane.
Step 1: Load the data
Import your source (Excel, CSV or database). Make sure you have a table with columns that represent the group (e.g.: Region), the category (e.g.: Product) and the numeric value (e.g.: Sales).
Step 2: Create the required measures
You need two measures: the total by category and the group total to calculate the percentage. Create measures in the Modeling pane with DAX; this allows the calculation to respond to filters.
Total Value = SUM('Sales'[Value])
Total Value por Grupo =
CALCULATE(
[Total Value],
ALLEXCEPT('Sales', 'Sales'[Group])
)
Percentagem por Categoria =
DIVIDE([Total Value], [Total Value por Grupo], 0)
Explanation: Total Value sums the value; Total Value por Grupo fixes the context by Group using ALLEXCEPT; Percentagem por Categoria divides and handles division-by-zero with DIVIDE.
Step 3: Insert the chart and configure fields
In the Visualizations pane choose the Stacked bar chart visual. Drag:
- Axis: Group
- Legend: Category
- Values: the measure Percentagem por Categoria
By default Power BI may sum percentages and the result can be wrong. That's why we use a measure that already returns a value between 0 and 1 per category in the group context.
Step 4: Format the value axis as percentage
With the visual selected, go to Format > Data labels (or Values) and set the number format to Percent (%) with 0-1 decimal places as you prefer. This ensures the labels show 0%–100% instead of 0–1.
Step 5: Fix incorrect summation in Tooltip/Legend (if needed)
Common issue: Power BI tries to sum the percentages when you aggregate the field in the Values axis. To avoid this, also add the measure [Total Value] to the Tooltip to show the absolute value per category and remove the aggregation of the percentages by leaving only the Percentagem measure visible on the axis.
// Example of a Tooltip measure to show absolute values
Valor Absoluto Tooltip = [Total Value]
Then drag Valor Absoluto Tooltip to Tooltip on the visual. This way users see the percentage and the absolute value when hovering over the bars.
Step 6: Add conditional formatting
You can highlight categories with percentages above a threshold (e.g.: 50%). Create a boolean measure and use it to format the color of the labels or the bar.
Destacar >50% = IF([Percentagem por Categoria] > 0.5, 1, 0)
In the visual go to Format > Data colors > Conditional formatting and choose Base on field = Destacar >50% and set two colors: one for 1 (highlighted) and another for 0.
Verify the result
Test with different filters (slicers by year, region, etc.). Each grouped bar (Group) should visually total 100% and the tooltips should show the percentage and the absolute value. Common errors: percentages that do not total 100% indicate that the Percentagem por Categoria measure is not using ALLEXCEPT correctly or that there are unwanted filters.
Conclusion
You now have a 100% stacked bar chart in Power BI that compares proportions by group and shows absolute values in the tooltip. Next steps: experiment with 100% stacked horizontal vs vertical, add hierarchies in the Axis, or calculate running percentage. Tip: always validate measures with a simple table to confirm that percentages and totals match.