1 Reply Latest reply on Jan 9, 2014 11:56 AM by Tracy Rodgers

    Getting the value for the Last N days

    Joefer Tingson

      Hi,

       

      I would like to know if the following is possible in Tableau:

       

      Scenario:

      Let say I have a 1 year data of sales starting from Jan 2013 to Dec 2013. In the dashboard, there should be a score card showing the following:

      YTD sales

      MTD sales

      Last 7 day sales

       

      I was able show the YTD and MTD sales. However, I am having difficulty showing the Last 7 day sales. The last 7 day sales should change its value everytime the date filter is changed by the user.

       

      Hope to hear from you soon.

       

      thanks,

       

      JF

        • 1. Re: Getting the value for the Last N days
          Tracy Rodgers

          Hi Joefer,

           

          The following calculation can be used if you're trying to find the last 7 days relative to today:

           

          if [Order Date]>=dateadd('day', -7, today()) then Sales end

           

          If relative to the latest date in the view, change the calculation to be similar to:

           

          if max([Order Date])>=dateadd('day', -7, window_max(max([Order Date]))) then sum(Sales) end

           

          Hope this helps!

           

          -Tracy