2 Replies Latest reply on Jun 28, 2018 5:48 AM by Ayub Keshtmand

# How to output the difference between two table calculations?

Version: 10.3

Data source: Sample - EU Superstore

Workbook: matrix table test.twbx

Previous post: Re: Simple Fixed Calculation?

What I have:

• All sheets - I have a matrix/pivot table/text table with subcategory against country for Sales.
• Sheet 1 - I have 4 measure values: Sum of Sales, % of Total Sum of Sales, Sum of Sales (Excluding Country) and % of Total Sum of Sales (Excluding Country)
• Sheet 2 - Checks to see if the Sum of Sales (Excluding Country) calculations are correct
• Sheet 3 - Extension of Sheet 1 using a parameter to filter across measures (e.g. Sum of Profit instead of Sum of Sales)

What I want to do:

• Include another value within each cell to show the difference between % of Total Sum of Sales and % of Total Sum of Sales (Excluding Country)
• E.g. for the below screenshot, under Accessories/Austria I want a field showing 2.93% - 5.55% = -2.62%
• Accessories/Belgium: 2.27% - 5.55%
• Appliances/Austria: 2.32% - 9.37%
• Appliances/Belgium: 3.75% - 9.37%

• Ideally I would like for this to work with Sheet 3's parameter/calculated field - but if it isn't possible then I will be ok with just the Sales metric.

Hope that all makes sense, any help would be greatly appreciated.

• ###### 1. Re: How to output the difference between two table calculations?

hi Ayub,

Firstly thanks for such an excellently worded/structured question. Very clear what you wanted, the Tableau version number and an example workbook...the big 3

So yes we can do this. First thing we can do, and this is a handy little trick. You have used the "Quick Table Calc" to create the % of totals...and this is just a short cut to get Tableau to write the formulas for us (we could just write them ourselves). But we can just CRTL+Drag the field onto the Measures Pane and now it's a re-usable calculation (we also get the option to rename it). I've attached a .GIF showing how (for some reason the forum isn't allowing me to embed this in the thread!)

Once we do this with your 2 formulas, we can just use them to create the difference calculation

[% of Sales Diff Total vs Exclude]

[% of Sales]

-

[% of Sales (Exclude)]

btw You can do exactly the same for your My Metric versions, for sheet 3

Hope that makes sense, and solves your issue, but let me know if not

• ###### 2. Re: How to output the difference between two table calculations?

Top Data Legend Simon Runc! Appreciate the help (and compliment) (Y)

Thanks!