6 Replies Latest reply on May 5, 2016 11:19 AM by youngji seo

# How do I get the previous year if the day is different?

Hi I used this formula: DATEADD('year',-1,[Date Selector])

but it is giving me exactly 1 year prior for ex 9/30/2016 --> 9/30/2015 which doesn't exist in my data set since it is business month end only. How do I change it so that it looks to the prior year and month and does not take into account the day? If the prior year is 9/29/2015 for ex.

Thank you!

• ###### 1. Re: How do I get the previous year if the day is different?

Does this: How do I change it so that it looks to the prior year and month and does not take into account the day?

But I don't suspect that's the whole story, or solution.

--Shawn

• ###### 2. Re: How do I get the previous year if the day is different?

Hi yea that gets to that portion of the answer but here are my dates:

So I want a formula where given the current date lets say 11/30/2015, it would return to me the previous year date of 11/28/2014. Please lmk if you have any ideas! thank you!

• ###### 3. Re: How do I get the previous year if the day is different?

This might work:

DATEADD('year', -1, DATETRUNC('week', [Date Selector])) + 6

--Shawn

• ###### 4. Re: How do I get the previous year if the day is different?

that only works for some dates but not all. thank you though. This is where I get very frustrated w/ Tableau and end up doing any slightly complicated calcs outside of tableau. ugh.

• ###### 5. Re: How do I get the previous year if the day is different?

If you provided a packaged workbook with some sample data, we could better help you from becoming frustrated. So far I've just been playing the guessing game. Set up the viz the way you want with some sample data and I'm sure there's a Tableau calc that will solve your problem. At this point I don't even know what you're wanting to use your formula for.

--Shawn

• ###### 6. Re: How do I get the previous year if the day is different?

I tried to filter out everything else so I can just show the dates since I can't share the rest of the data. But all I want to do is use the date selector and have it bring up the current and previous. For april it works but not for other months. I shoudl have mentioned earlier these are business month end dates.