5 Replies Latest reply on Nov 19, 2014 10:17 AM by Matt Lutton

# Calculating Difference Between Years

Hi, new to tableau. I am hoping this is straightforward ...

My excel data that I connect in tableau looks like this:

ProductSalesYear to date
A£50031/122009
A£75031/12/2010
A£100031/12/2011
B£80031/12/2009
B£70031/12/2010
B£10031/12/2011
And so on

I can use the year to date column to produce line graphs and tables which I can then filter by product - great!

What I need to be able to do is calculate the actual difference in sales between the years - how can I do this if the years are in the same variable?

T

• ###### 1. Re: Calculating Difference Between Years

If you can take these sample records, copy them into Excel, extract that data and post the TWBX file here, someone will be happy to show you how you can do this.  See also: Posting a Perfect Question

Cheers!

• ###### 2. Re: Calculating Difference Between Years

OK. Here you go ...

• ###### 3. Re: Calculating Difference Between Years

In the attached, I created a Quick Table Calculation on the SUM(Sales) pill for "Difference", and set the "Compute Using" (addressing dimension) to be on the Date field.

Then, I displayed your line graph to show the Sum of Sales for each year, as well as the Difference value in 2010 and 2011.  There is no value for the first year, so no difference appears there.

If this is not what you're after, please provide a mock-up of the results you'd like to see in Tableau.

I hope this helps -- cheers.

1 of 1 people found this helpful
• ###### 4. Re: Calculating Difference Between Years

Thank you, ever so nearly there, it is now a question or format. I would like the table in the original twbx file to look like this:

Header 1200920102011Difference between 2009 - 2011
Sales£100£250£500£400

I cannot put the calculated field into a column at the end of the table.

• ###### 5. Re: Calculating Difference Between Years

Yeah, that may be difficult with your current structure.  It is possible to do this using two sheets on a dashboard.  There are likely other ways, but this was quick and easy in this example: