3 Replies Latest reply on Jan 6, 2016 11:59 AM by rahul.patel.2

# I have to create a report where i need to show the sales of 1]current week 2]Previous week and 3]the same week of last year?

For example.

If i am showing sales for current week 2(2015) .  I also need to show sales for previous week 1(2015) . Also i need to show the past years current week (so that is week 1 of 2014), Can anyone help me out please?

The version i am using is Tableau 8.3,

Thanks

• ###### 1. Re: I have to create a report where i need to show the sales of 1]current week 2]Previous week and 3]the same week of last year?

Can you create additional calculated field, where you wil be comparing current date to the dates in data set? If the data in a given row >= today-21days then "show" else "hide". Then you may filter the outcomes to show only "show".

• ###### 2. Re: I have to create a report where i need to show the sales of 1]current week 2]Previous week and 3]the same week of last year?

I wrote up how to do something similar to this quite a while ago in this post: Recreate the Omniture visits report in Tableau - part 2 and also further looking at date filters here: Tableau Advanced Date Filters

Michal is heading in the right direction, you'll need to write a calculated field to return only values for this week, previous week and this week last year, something such as:

If datetrunc('week',date)  = datetrunc('week',now()) then 'Show'

elseif datetrunc('week',date)  = datetrunc('week',dateadd('week',-1,now()) then 'Show'

elseif datetrunc('week',date)  = datetrunc('week',dateadd('year',-1,now()) then 'Show'

else 'Hide'

end

Put this calculated field on the filter shelf (and test it as the syntax may not be perfect as I've written this directly into the post without testing) and filter for Show or exclude Hide.

2 of 2 people found this helpful
• ###### 3. Re: I have to create a report where i need to show the sales of 1]current week 2]Previous week and 3]the same week of last year?

Thank You for your help guys. I also found out a post which is similar to this question. Sharing you the link please check it out.

Thanks again Michal Ejchman Andrew Watson

1 of 1 people found this helpful