Power Bi Add Total To Stacked Bar Chart
Power BI is a data visualization tool that helps businesses to analyze data and make informed decisions. It enables users to create interactive reports and dashboards that can be easily shared across the organization. Stacked bar charts are a popular visualization type in Power BI, which displays data in a series of horizontal bars. In this article, we will discuss how to add total to stacked bar chart in Power BI.
What is a Stacked Bar Chart in Power BI?
A stacked bar chart in Power BI is a type of chart that displays data in a series of horizontal bars. Each bar represents a category, and the height of the bar represents the value of the category. The bar is divided into segments, where each segment represents a subcategory. The length of the segment represents the value of the subcategory.
Adding Total to Stacked Bar Chart in Power BI
Adding total to stacked bar chart in Power BI is a useful feature that helps to provide a better understanding of the data. It enables users to quickly identify the total value of each category and subcategory. There are two methods to add total to stacked bar chart in Power BI.
Method 1: Using the Image URL
The first method to add total to stacked bar chart in Power BI is by using the image URL. This method involves adding an image URL to the stacked bar chart, which displays the total value of each category and subcategory. Follow the steps below to add total to stacked bar chart in Power BI using the image URL.
- Open Power BI Desktop and select the stacked bar chart that you want to add the total to.
- Click on the Format tab in the Visualizations pane.
- Scroll down to the Data labels section and turn on the Category labels and Value labels.
- Click on the Value labels drop-down menu and select Custom.
- In the Custom format string field, enter the following formula:
- Click on the OK button to save the changes.
- Open the web browser and search for the image URL that displays the total value.
- Copy the image URL and go back to Power BI Desktop.
- Click on the stacked bar chart and go to the Format tab in the Visualizations pane.
- Scroll down to the Data label section and turn on the Category labels, Value labels, and Total labels.
- Click on the Total label drop-down menu and select Custom.
- In the Custom label field, enter the following formula:
- Replace the "Image URL" with the image URL that you copied in step 7.
- Click on the OK button to save the changes.
#,0;(#,0);0
"<img src='" & "Image URL" & "'>" & "<br>" & "Total: " & SUM([Value])
Method 2: Using the Measure
The second method to add total to stacked bar chart in Power BI is by using the measure. This method involves creating a measure that calculates the total value of each category and subcategory. Follow the steps below to add total to stacked bar chart in Power BI using the measure.
- Open Power BI Desktop and select the stacked bar chart that you want to add the total to.
- Click on the Format tab in the Visualizations pane.
- Scroll down to the Data labels section and turn on the Category labels and Value labels.
- Click on the Value labels drop-down menu and select Custom.
- In the Custom format string field, enter the following formula:
- Click on the OK button to save the changes.
- Click on the New measure button in the Fields pane.
- In the formula bar, enter the following formula:
- Click on the Checkmark button to save the measure.
- Click on the stacked bar chart and go to the Format tab in the Visualizations pane.
- Scroll down to the Data label section and turn on the Category labels, Value labels, and Total labels.
- Click on the Total label drop-down menu and select Value.
- Click on the Total label drop-down menu again and select the measure that you created in step 8.
- Click on the OK button to save the changes.
#,0;(#,0);0
Total = SUM([Value])
Conclusion
Adding total to stacked bar chart in Power BI is a simple yet powerful feature that helps to provide a better understanding of the data. It enables users to quickly identify the total value of each category and subcategory. In this article, we have discussed two methods to add total to stacked bar chart in Power BI. The first method involves using the image URL, while the second method involves using the measure. Both methods are effective and can be used depending on the user's preference.