13 Replies Latest reply on Apr 26, 2018 11:29 PM by Ci Song

# Q4-Q1 yoy comparison

Hi friends,

I'm working on to have a line chart but cannot make it. Hope one of you can help:

I have the daily sales data from 2016/1/1 - 2018/3/31. And I would like to get 2 lines in one chart, which can compare 2016Q4-2017Q1 vs 2017Q4-2018Q1 by month-date.

I have a sample chart made in excel like below:

What are your suggestions to handle this?

Thanks so much!

Ci

• ###### 1. Re: Q4-Q1 yoy comparison

Ci,

One solution would be to create two calculations for Sales, one for each time period. An example would look like this:

IF [Order Date] >= #10/1/2016# and [Order Date] <= #3/31/2017#

THEN [Sales]

END

IF [Order Date] >= #10/1/2017# and [Order Date] <= #3/31/2018#

THEN [Sales]

END

Put these calculations on the Rows shelf. Then put the discrete date part Month(Date) on the Columns shelf. You can then either do a dual axis with the two sales calculations or use Measure Names and Measure Values to create multiple lines on the same chart.

I've attached a workbook as an example.

-Wesley

If this post 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.

1 of 1 people found this helpful
• ###### 2. Re: Q4-Q1 yoy comparison

Hi, Ci Song

Is there any sample workbook can be shared so that it will easier to help

ZZ

• ###### 3. Re: Q4-Q1 yoy comparison

You could bring your MONTH(date field) onto your Columns shelf, your sales data to Rows, and then bring YEAR(date field) to the color mark.

• ###### 4. Re: Q4-Q1 yoy comparison

Hi Wesley,

Thanks for helping to answer this so quickly.

I do want to show the lines in a daily view instead of monthly. Then how should I handle the label of x axis to only show Month-Date, not by year?

I changed into daily and it's shown like below:

Thanks!

Ci

• ###### 5. Re: Q4-Q1 yoy comparison

Attached. Thanks for helping with it.

• ###### 6. Re: Q4-Q1 yoy comparison

Ci,

Instead of using m/d/yyyy you'll need to use a date part of Month/Day. This doesn't exist as a default in Tableau. One solution would be to create your own that would look like this:

STR(DATEPART('month',[Order Date]))+ '/' + STR(DATEPART('day',[Order Date]))

There are probably other solutions, but this pretty straightforward.

-Wesley

If this post 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.

1 of 1 people found this helpful
• ###### 7. Re: Q4-Q1 yoy comparison

Hi, Ci

Hope this helps

ZZ

• ###### 8. Re: Q4-Q1 yoy comparison

Hi Wesley,

Thanks for providing the inputs. I think you method is good if I only want to compare one measures. But it might be too much work if i'd like to compare more than 10 measures since i need to add 2 calculated fields for each measures.

Thanks!

Ci

• ###### 9. Re: Q4-Q1 yoy comparison

Thanks for your help. One issue for your solution is that the chart is not continuous and cannot showing the trend. Do you have any suggestions to fix this?

Thanks!

Ci

• ###### 10. Re: Q4-Q1 yoy comparison

Hi, Ci

Here you go

Let me know if you have question.

ZZ

1 of 1 people found this helpful
• ###### 11. Re: Q4-Q1 yoy comparison

sorry.  MAKEDATE is not working for me since I'm using live data... do you have any other suggestions?

Thanks!

Ci

• ###### 12. Re: Q4-Q1 yoy comparison

Hi, Ci

Then try this one

ZZ