7 Replies Latest reply on Nov 9, 2018 11:57 PM by Gopal Yadav

# weekly comparison chart in tableau

Need to perform weekly comparison calculations in Tableau. to compare last five years weekly sales.

Problem statement:- The sales metrics showing up to today (Saturday, First week, November 2018), so want to to compare same time period of last five years.

Like Compare November First week 2018 to November first week 2017,,,,,so on.

Ex

 2018 Sales 2017 Sales 2016 Sales 5/11/2018 123 6/11/2017 234 7/11/2016 234 6/11/2018 345 7/11/2017 345 8/11/2016 345 7/11/2018 900 8/11/2017 789 9/11/2016 789 8/11/2018 234 9/11/2017 456 10/11/2016 456 9/11/2018 567 10/11/2017 123 11/11/2016 123

• ###### 1. Re: weekly comparison chart in tableau

Hi Gopal

Here the formulas used to compute weekly sales

Current Year:

if datediff('year',date,today())=0

and datediff('month',date,today())=0

and datediff('week',date,today())=0

then [sales] end

Last Year Same Week:

if datediff('year',date,today())=1

and datediff('month',date,today())=0

and datediff('week',date,today())=0

then [sales] end

2 Years back Same Week:

if datediff('year',date,today())=2

and datediff('month',date,today())=0

and datediff('week',date,today())=0

then [sales] end

Instead of today() use can also use a date parameter to control the dashboard

1 of 1 people found this helpful
• ###### 2. Re: weekly comparison chart in tableau

Hi Akram - i really appreciate your effort, but I'm not getting what i expected.

I want to compare this week sales previous year same week sales using above formula I'm seeing any result.

• ###### 3. Re: weekly comparison chart in tableau

Can you share the screenshot of the error with some mock data in excel with expected output?

It will be helpful for me to give you same output

• ###### 4. Re: weekly comparison chart in tableau

Hi Akram - Please find attached file, above top of question.

• ###### 5. Re: weekly comparison chart in tableau

Hi Gopal,

Below is one of the way (simple one if you allow Week Numbers)

NOTE: Weekday should be a dimension

Thanks,

Ritesh

• ###### 6. Re: weekly comparison chart in tableau

You can add Month filter as well as below

Ritesh

2 of 2 people found this helpful
• ###### 7. Re: weekly comparison chart in tableau

Its working.

thank you so much for all your help i really appreciate it Ritesh.