1 2 Previous Next 16 Replies Latest reply on Jul 12, 2019 1:41 AM by Chaitanya Kulkarni

# Last Year to Latest Quarter Sale Difference

Hi Tableau Community,

I'm trying to calculate last year (2017) sales minus current year (2018) quarter (Q4) sales difference.

Any help with above calculation greatly appreciated.

So I want to show Last Year Sales and Current Qtr Sales.

And The difference b/w them

Regards,

Chaitanya

• ###### 1. Re: Last Year to Latest Quarter Sale Difference

SUM(IF YEAR([Order Date])=2018 THEN [Sales] END)-

SUM(IF YEAR([Order Date])=2019 and DATENAME('quarter',[Order Date])='3' THEN [Sales] END)

or

SUM(IF YEAR([Order Date])=YEAR(TODAY())-1 THEN [Sales] END)-

SUM(IF YEAR([Order Date])=YEAR(TODAY()) and DATENAME('quarter',[Order Date])=DATENAME('quarter',TODAY()) THEN [Sales] END)

• ###### 2. Re: Last Year to Latest Quarter Sale Difference

Hi,

Thank you so much for the response.

I did tried the both calculations, however it is not showing any results to be.

Regards,

Chaitanya

• ###### 3. Re: Last Year to Latest Quarter Sale Difference

Can you attach a workbook?

• ###### 4. Re: Last Year to Latest Quarter Sale Difference

Hey Chaitanya,

Is it possible to share the workbook with us.

Regards

Aashish

• ###### 5. Re: Last Year to Latest Quarter Sale Difference

Attached

• ###### 6. Re: Last Year to Latest Quarter Sale Difference

Use This

SUM(IF YEAR([Order Date])=2017 THEN [Sales] END)-

SUM(IF YEAR([Order Date])=2018 and DATENAME('quarter',[Order Date])='3' THEN [Sales] END)

• ###### 7. Re: Last Year to Latest Quarter Sale Difference

Hi chaitanya,

How you compare last year sales with current year current quarter sales.

Compare up to last year same quarter and up to current quarter sales can compare right.

SUM(IF YEAR([Order Date])=2017 THEN [Sales] END)-

SUM(IF YEAR([Order Date])=2018 and DATEPART('quarter',[Order Date])=3 THEN [Sales] END)

Thanks

sankar

• ###### 8. Re: Last Year to Latest Quarter Sale Difference

Regards

Aashish

• ###### 9. Re: Last Year to Latest Quarter Sale Difference

Hi Sankar,

I understand, but something that I my requirement to compare last year sales with latest quarter sales.

Regards,

Chaitanya

• ###### 10. Re: Last Year to Latest Quarter Sale Difference

hi

Difference

SUM(IF YEAR([Order Date])=2017 THEN [Sales] END)-

SUM(IF YEAR([Order Date])=2018 and DATEPART('quarter',[Order Date])=3 THEN [Sales] END)

thanks

sankar

• ###### 11. Re: Last Year to Latest Quarter Sale Difference
1 of 1 people found this helpful

• ###### 13. Re: Last Year to Latest Quarter Sale Difference

version 10.5

• ###### 14. Re: Last Year to Latest Quarter Sale Difference

Here's how I would approach the color challenge.

You've got a crosstab of discrete date values across the top and a dimensional breakdown on the left. I'll filter this down to 2 years of data: From here I'll write a calculation to determine the difference between the value in one pane (2017 in this case) and the corresponding value in the other pane (2018). Since we're comparing values within the same table of data, we'll use a Table Calculation: Since it's a table calculation, we can specify which values are being compared with which. I configured it like this: We tell Tableau to compute it at the Year level, which we can see by the fact that there aren't any values for the first year, but there are for the second. From here, let's ctrl+drag that calculation pill to color. Also, we don't want to show the 2017 values, but we still need that data in the view (so that the calculation can work). We solve this by right clicking the 2017 header and selecting Hide. A little formatting and the result looks like this: Using a combination of table calculations and subsequent hidden panes is a really nice and clean way to present data like this. If this answered your question, please mark as correct so that other people can benefit from the solution as well!

Thanks,

Vince

2 of 2 people found this helpful
1 2 Previous Next