KNOWLEDGE BASE

## Creating a Discrete Stacked Bar Chart for Discrete Percentages

Published: 22 Dec 2016

### Question

How to create a discrete stacked bar chart by percentage.

### Environment

Tableau Desktop

1. Create a percentage of total calculation called [Cross-Category %], using a dimension. For example, in the Global Superstore sample data, if [Category] is in the view, the following calculation will show each [Category] value's percentage of the total [Sales]:
```SUM( [Sales] )
/
SUM( {EXCLUDE [Category] : SUM([Sales])} )```
2. Drag the dimension to "Color" on the Marks card.
3. Create a calculated field called [Display] to generate a number of asterisks or other characters based on the size of each percentage:
```REPLACE(

SPACE(  ROUND( [Cross-Category %], 1 ) * 10  )

, " " , "*" )```
4. Set the Mark type to Text and drag [Display] to Text.
The above steps will result in approximately ten asterisks to represent percentages of the SUM( [Sales] ) by [Category].

The above steps can be reviewed in the attached workbook: Discrete Percentage Bins.twbx.