1 Reply Latest reply on Jul 19, 2016 1:50 PM by Tom W

    Tableau extract filter to always take top n most recent?

    jenn.ng

      I have a CSV file where i add in a new date range (string format) every week.

      Currently i have to manually pick out the top 5 most recent week string for my extract filter in the data source tab. How can this be done automatically using wildcard,condition, or limit? In my csv file, the newest week string will always be at the bottom so it is ordered. When it goes into tableau, the order is gone.

       

      Screen Shot 2016-07-19 at 1.03.00 PM.png

        • 1. Re: Tableau extract filter to always take top n most recent?
          Tom W

          Firstly, I'd extract the start / end date from your string so you can work with a real date field. I.e;

           

          DATEPARSE("MM/dd/yy",left([Week],8))

           

           

          Then, right click your source, select 'Edit Data Source Filters', click add, select your new 'Week Start' field you selected above, select 'Individual Dates and times'.

          In the filter window, select the 'Top' tab, click 'By field' and set it to Top 5 by WeekStart and set the 'Count' aggregation to Maximum.