1 Reply Latest reply on Aug 20, 2018 8:12 AM by Naveen B

    Filter last 7 days w/ the days in the database

    Alex Camatti

      Hello,

       

      I've been searching in the foruns by a solution but nothing founded.

      I have dates that dont include the weekends, only monday - friday because the company dont open in weekends. So, i need to filter the last 7 days with the dates that i have in my datasource / database. For example, if today is August 20th, so my last 7 days  needs to be August 10th, today are included in the calc. I just need to limit my registers to 7 days. Calculated fields  like LAST() < 7 dont work because there are others registers that cant be ignored, and when i use LAST() < 7 some of these registers disappear. the logic is a quite simple, if i can get the COUNTD([Date]), how do i tell to tableau that he needs to get the last 7 COUNTD([Date])?

        • 1. Re: Filter last 7 days w/ the days in the database
          Naveen B

          Hi Alex,

           

          Click on Last Calculation --> Compute using --> Selected Dimensions--> Restart every "Register"

           

          so that Last calculation will apply for each register

           

          Other way would be

           

          Create a calculated field to get the register wise maximum date like below

           

          RegionWiseMaxDate:

          {Fixed [Register]:Max(Date)}

           

          Filter calculation for last 7 days

           

          datediff('day',date,RegionWiseMaxDate) < 7 and datediff('day',date,RegionWiseMaxDate) > 0

           

          place the filter calculation in filter and Select True

           

          If any dimension filters are there add that to context

           

          Hope this helps kindly mark this answer as helpful or correct so that it will help others

           

          BR,

          NB