3 Replies Latest reply on Sep 30, 2018 11:58 PM by Boroon Mahanta

# n-1 formula within a range of numbers

Hi, I am interested in learning how to create a formula that computes the previous value within a set. Use case is a month-over-month or week-over-week comparison.

1st use-case

Months:

[1,2,3,4,5,6,7,8,9,10,11,12]

On Month 1, this should compare to previous year's Month 12.

2nd use-case

Fiscal Weeks

[1,2,3,4,5,6,...52,53*]

Sometimes in a fiscal calendar will include a 53rd week. How does one formulate a calculation to take week-over-week on Week 1 and identify whether it should be compared to previous year's Week 53 or 52?

• ###### 1. Re: n-1 formula within a range of numbers

Hello Alec,

Examples of date calculations are in the The specified item was not found. and Workbook & Calculation Library and then there is a great Think Data Thursday presentation from Rody Zakovich called Think Data Thursday: Dating Rody that you may also find helpful.

If there is not a solution to be found in those resources, please come back here and post a Tableau Packaged workbook showing an example of the data and visualization that you are trying to create.  The answers for this may be different depending on the type of visualization being created and what you are trying to convey.  Please be sure to include a Tableau Version number with your .TWBX file.

Thank you

Patrick

1 of 1 people found this helpful
• ###### 2. Re: n-1 formula within a range of numbers

Thanks Patrick, I was able to figure it out using a a few IF statements.

• ###### 3. Re: n-1 formula within a range of numbers

Hi Alec, it would be great if you could share your learnings for other members of the community to learn from you? Are you ok to share your formula or direct me to a source. Thanks in advance.