5 Replies Latest reply on Nov 27, 2012 4:44 PM by Aaron Rubinstein

# Calculating the Sum of a Weighted Percent Change

In the attached workbook I am calculating the percent change in prices of two products over time, and I have weighted those percent changes based on the proportion of my overall cost that each product represents (Product A is 70%, Product B is 30%).

What I am trying to do now is add an additional line to the chart that would show the sum of the weighted percent changes in Product A and Product B. In other words, for each date I need to add the weighted percent change in Product A to the weighted percent change in Product B, and chart that as a new line. I cannot figure out how to set this up correctly; any help would be appreciated.

The correct values for the new line should be as follows:

 Date Overall % Change 1/1/2011 0.00% 2/1/2011 1.45% 3/1/2011 6.15% 4/1/2011 9.60% 5/1/2011 4.65% 6/1/2011 8.35% 7/1/2011 9.55% 8/1/2011 10.25% 9/1/2011 8.50% 10/1/2011 10.00% 11/1/2011 12.85% 12/1/2011 15.45%
• ###### 1. Re: Calculating the Sum of a Weighted Percent Change

In case it helps, I have attached an Excel workbook that has an example of the chart I am trying to setup in Tableau. I can get the "Weighted % Change" for Product A and B using a table calc, but I cannot figure out how to chart the "Overall Weighted Cost Change" which is the sum of the Weighted % Change for each product.

• ###### 2. Re: Calculating the Sum of a Weighted Percent Change

Hi Aaron,

You can do this by creating a calculation similar to the following and creating a dual axis with Weighted % Change:

window_sum([Weighted % Change])

I have attached the workbook.

Hope this helps!

-Tracy

• ###### 3. Re: Calculating the Sum of a Weighted Percent Change

Perfect, thanks Tracy! I'm still trying to wrap my head around table calculations.

Do you know if it's possible to hide the second axis, since it is kind of redundant in this example (same scale and units)?

• ###### 4. Re: Calculating the Sum of a Weighted Percent Change

Glad I was able to help! Right click on Sum of Weighted % Change on the rows shelf and un-check 'Show Header.'

• ###### 5. Re: Calculating the Sum of a Weighted Percent Change

Awesome, thanks again!