4 Replies Latest reply on Jun 26, 2018 8:44 AM by andre riley

    This Time Last Year

    andre riley

      Hi Tableau World,


      I need help with creating a calculation for use as a filter. I'm showing data for the past 4 weeks but want to put that into context by showing the data over the same period last year. Any help would be much appreciated!




        • 1. Re: This Time Last Year
          Tushar  More

          Hi Andre,


          Pl check the thread below.



          Hope this will give you idea.



          • 2. Re: This Time Last Year
            andre riley

            Hi Tushar,


            While interesting, the shared link isn't exactly what I'm looking for. Without the consumer of the report having to manipulate the parameter in order to keep the date updated, I want to anchor last year's data relevant to TODAY(). The intent is to show how holidays have historically affected sales while the period being viewed stay current based on when the report is generated. I hope this clarifies the ask.




            • 3. Re: This Time Last Year



              Your will need to create two calculated fields. It depends if you want the period to be based on the actual day or on the week that the day falls within. I will assume that want you want is the week # that the day falls within. If it isn’t, change the formula to be based on day instead.  Remember Tableau starts it’s counts on 0 not 1. [Data] is whatever date field you are basing everything off of.


              Current Period:   Datediff(‘week’,[Date],Today()) <= 3


              Prior Period: Datediff(‘week’,[Date],Today()) >= 52 and Datediff(‘week’,[Date],Today()) <= 55


              This will tag your data with true/false for the periods you are interested in. Then it depends on how you want to display it.  Single value comparison, bar chart, etc.



              • 4. Re: This Time Last Year
                andre riley

                Hi Garth,


                I haven't plugged this in just yet but the logic sounds like what I'm looking for. I'll follow up if necessary. I greatly appreciate your time!