7 Replies Latest reply on Apr 11, 2018 4:20 AM by Jim Dehner

# How to calculate difference between percent of total percentages

Hi,

I need to calculate the difference between two percentages calculated as percent of total. Here is an example of what I am trying to achieve:

The percentages above are percent of total calculations. I need to display the difference (66.95 - 67.94 and 33.05 - 32.06) between the percentages in another table.

Thanks!

• ###### 1. Re: How to calculate difference between percent of total percentages

Hi Karan,

To create the difference of your percentages in another table, you will need to create the percentages as new measures. The problem lies in that table calculations are computed locally and depend on the fields in the view. There is a way to create these fields using level of detail expressions, however, and there is a step by step of how to create these in Exercise 4: Top 15 Tableau LOD Expressions (Practical Examples).

Let me know how you get on and if you need any further assistance.

Cheers,

Sasha

• ###### 2. Re: How to calculate difference between percent of total percentages

Good morning

first calculate percent of total with an LOD (not table calculations

then use a lookup function to calculate the difference

in a text table it returns this

or in a summary it looks like this

Jim

If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

• ###### 3. Re: How to calculate difference between percent of total percentages

Thank you Jim. And apologies for being late to reply.

Your solution would perfectly work in a normal scenario. However, I am having trouble implementing this in my case. I cannot use LOD expressions in my calculations since I have multiple data sources using blend.

If I try to use table calculation "SUM(Sales)/TOTAL(SUM(SALES))" for percent of total value then I have to tell Tableau to compute the results using Table(down). But while calculating the difference this calculation still computes the result using default table calculation(Table(across)) and gives me incorrect results.

Thanks,

Karan

• ###### 4. Re: How to calculate difference between percent of total percentages

Thanks Sasha. Please see my other post for the issue I am facing with this approach.

Karan

• ###### 5. Re: How to calculate difference between percent of total percentages

Hi

sorry but when you don't show us your twbx workbook we just have to assume what you need

because you are using table calculations you will need to nest the difference calculation and the % of total

the create a second calculation for the difference

Open the difference calculation and set the inner calculation (% of total) as shown

then open it again and set the outer calculation as shown

it will return this

Jim

1 of 1 people found this helpful
• ###### 6. Re: How to calculate difference between percent of total percentages

Thank you so much Jim. It worked for me.

Karan

• ###### 7. Re: How to calculate difference between percent of total percentages

Thanks