Power BI - Stacked Bar Chart



What is a Stacked Bar Chart?

A Stacked Bar chart that displays the data values in the two-dimensional horizontal stacked rectangle without overlapping. The horizontal stacked bar represents a subset of the total, and the various partitions of each horizontal bar show how each category leads to the whole.

How to Create a Stacked Bar Chart?

Dataset − You can import the sl.xlsx "D:\Dataset_excel\sl.xlsx" before creating the Stacked Bar chart.

Case Study 1

In the given dataset, Sales production for various years in different countries is given. Richard needs to generate the Stacked bar chart of the following questions.

  • What is the sales production in 2023 years of different countries?
  • What is the sales production in 2020 and 2021 years of various countries through a Stacked Bar chart? Also, explain each section of the Stacked bar chart in detail.

Step 1 − Richard navigates to the Report View and selects the "Stacked Bar chart" from Visualizations.

Create a Stacked Bar Chart

Step 2 − Richard added the "Country" field to the Y-axis and the "Sales production in 2023" field to the X-axis.

Create a Stacked Bar Chart 1

As you may notice in the screenshot, the Sum of sales production in 2023 categorized by country is shown.

Step 3 − The next step is to alter the fields of the X-axis. He can add the "Sales production in 2020" and "Sales production in 2021" fields to the X-axis. As you can observe in the screenshot, the colorful Stacked Bar chart has been developed that shows the Sum of Sales production in 2020 and the Sum of Sales production in 2021 by country.

Create a Stacked Bar Chart 2

Note: In the above screenshot, the visual is shown in Focus Mode.

Step 4 − The next feature is Legend which shows the different countries in various color. To activate this feature, remove the "Sum of Sales Production in 2020" as the "Legend" will not function if more than one field is being placed on the X-axis. Place the "Country" field to the "Legend".

Create a Stacked Bar Chart 3

As you can observe in the screenshot, the colorful Stacked bar chart has been populated on the canvas.

Step 5 − Richard may also partition the generated visual into various independent visuals through the usage of the "Small multiples" section. He will place "Sales production in 2023" into the "Small Multiples".

Create a Stacked Bar Chart 4

Step 6 − Richard can see only two pieces of information that is "Country Name" and "Sum of Sales production in 2021" when he places the cursor on the specific bar.

Create a Stacked Bar Chart 5

To view more extensive information about other fields, he adds "Sales production in 2020" and "Sales production in 2023" into the "Tooltips" section.

Create a Stacked Bar Chart 6

Step 7 − Richard will use the "Drill through" section where he can filter the field values. Suppose he just wants to see the Sales production of Argentina country. In that case, he needs to add the "Country" to the Drill through the section, select the "Used as Category" option from the drop-down menu, and select the "Argentina" country.

Create a Stacked Bar Chart 7

How to Format a Stacked Bar Chart?

Once he clicks on Format Visual, two options "Visual" and "General" are available. The General comprises various options like Properties, Titles, Effects, Header icons, Tooltips, and Alt text.

Format Stacked Bar Chart

Step 1 − The Properties option consists of four sections Size, Position, Padding, and Advanced Options.

Format Stacked Bar Chart 1

He can expand the Size tile and increase or decrease the Height and Width of the visual.

Format Stacked Bar Chart 2

Step 2 − He can also turn off the supported title just by turning off the title button. Moreover, he can alter the default title name and modify it to "Stacked Bar Chart", set the heading to "Heading 2", and select the Font style "Comic Sans MS" to modify and set the font size to 29 and choose the Bold.

Format Stacked Bar Chart 3

Here, you can view in the screenshot, the title styling has been modified.

Similarly, he can alter the styling of the "Subtitle".

Format Stacked Bar Chart 4

Step 3 − Turn on the Background color and select the desired color from the drop-down list of listed colors.

Format Stacked Bar Chart 5

Step 4 − Two options "Colors" and "Icons" are available in the Header icons. The alteration which are applied to the Header icons will be showcased in the reading view.

Format Stacked Bar Chart 6

Step 5 − When he expands the Tooltips tile that comprises three sections "Options", "Text" and "Background".

Format Stacked Bar Chart 7

Lets change the font style to "Lucida Sans Unicode" and set the font size to 10, select Italic, modify the Label color, and choose the desired background color of the Tooltips.

Format Stacked Bar Chart 8

Step 7 − Now, Richard clicked on the "Visual" where multiple options like Small multiples, Gridlines, Zoom Slider, and so on are presented to enhance the visual appearance.

Format Stacked Bar Chart 9

Step 8 − Richard can alter the styling of the Gridlines. To achieve this, he can expand the Gridlines, select the "Solid" and alter its color, and set its width to "2px".

Format Stacked Bar Chart 10

Step 9 − You may turn the Data labels and Total labels option to display them on the different bars.

Format Stacked Bar Chart 11
Advertisements