6 Replies Latest reply on Oct 11, 2019 6:12 PM by vijay.kumar.10

# Percentage and Total in same stacked bar with multiple measures

Hi,

I have two measures for a stacked bar. Example: In superstore sales data - Whats the Sales % and Profit % under each customer segment.

I want to show the total of profit and sales near the % value. This is possible if we use one measure and one dimension. Is it possible to do the same when we have multiple measures.

Please suggest. Attaching my packaged workbook.

• ###### 1. Re: Percentage and Total in same stacked bar with multiple measures

So what's happening here is that the "grain" (or "granularity") of the data (for SuperStore) is by Product/Order....so the SubCategory Accessories, is made up of lots of rows of data. When you use the Profit/Sales the calculation is performed for each row, and then when you bring it into the canvas (I assume it has a SUM aggregate around it) it is SUMing up all the Profit/Sales for each row that makes up Accessories (which is why we get a silly value).

In your SUM(profit)/SUM(sales) all the rows for Profit are SUMed up, and then All the rows for Sales are SUMed up and then the division is done to get the margin. If you look at the pills in your table you'll see that the Profit and Sales have a SUM() aggregate, so the SUM(profit)/SUM(sales) (for Accessories) is doing 41,937/167,380 = 25.05%

• ###### 2. Re: Percentage and Total in same stacked bar with multiple measures

Hi Vijay,

Sorry i can't understand the question properly. Can you explain a bit more please? Perhaps with a sample of your expected output?

Manoj

• ###### 3. Re: Percentage and Total in same stacked bar with multiple measures

So basically the calculation we are showing is wrong as I am assuming. Am I

correct ?

On Fri, 11 Oct 2019 at 4:19 PM, selva kumar <tableaucommunity@tableau.com>

• ###### 4. Re: Percentage and Total in same stacked bar with multiple measures

I guess its showing the correct percentages for both profit and sales. But I'm sure if thats what you;re expecting.

manoj

• ###### 5. Re: Percentage and Total in same stacked bar with multiple measures

Say the sales percentage is x and profit percentage y in the stacked bar. I

need to show x %, sum(x) and same for y

On Fri, 11 Oct 2019 at 4:35 PM, Manoj Lobo <tableaucommunity@tableau.com>

• ###### 6. Re: Percentage and Total in same stacked bar with multiple measures

Yes that’s correct. But additionally I want the volume as well near to the

percentage label. Example. X%, sum(x sales).

On Sat, 12 Oct 2019 at 6:39 AM, Manoj Lobo <tableaucommunity@tableau.com>