3 Replies Latest reply on Aug 23, 2013 8:24 AM by Robin Kennedy

    Tableau 7 - Top 'N' filter issues

    Mike Fallone

      I am trying to create a worksheet showing the Top 10 pageviews and the count (sum of pageview) for the past week.  When I sort by Domain names (descending) the rankings look correct (i.e. domain1.com shows as a count of 377 and is the 3rd entry) (see tableau_no_filter.png).  Once I apply the Top filter (Domain > Filter > Top > By Field: Top 10 Pageviews Sum) I no longer see domain1.com (tableau_filter_applied.png).


      I have changed the worksheet to test only yesterday's data and I get the same result.  Why, when applying the filter does this domain (and others) not show up.


      Version Tableau 7.0.12

        • 1. Re: Tableau 7 - Top 'N' filter issues
          Robin Kennedy



          This occurs because the Top N filter happens before any of your other filters. I.e. it is filtering the top 10 domains by the sum of pageviews for your entire dataset, and then it applies the other filters. domain1.com is being filtered out by your other filters (perhaps the Useraccess = True one?)


          To get around this you have two options.


          1. Make your other filters happen before the Top N filter by making them Context Filters. Context filters always happen first, (they actually make a temp table in your data source and then Tableau queries this). To do this you have to right click the other filters and select 'Add to Context'. See more about context filters here: http://onlinehelp.tableausoftware.com/v7.0/pro/online/en-us/filtering_context.html


          2. Perform a top N filter by an alternative means - a table calculation. Since table calculations happen after normal filters, you can rank your data using the INDEX formula in a custom calculated field and then filter on that so that the field <= 10. See more on using INDEX to filter top 10 values here: http://www.theinformationlab.co.uk/2012/10/01/using-index-to-filter-top-n-values-within-a-category-video/

          • 2. Re: Tableau 7 - Top 'N' filter issues
            Thibault Reynier

            Dear Robin,


            Thank you very much for the tip with the context filters.

            However, one of my data is a parameter... Is it possible to add a parameter to a context?


            Otherwise using the index fonction does not work well because I am plotting a dual axis with two measures and the ranking seems to apply differently depending on the measure (I thought the ranking Index() function was something global and did not apply to one particular field). Therefore, the ranking varies a lot.


            I apologize for jumping into the thread but I think this particualrly fits the topic


            Thank you in advance for any pieces of advice!






            • 3. Re: Re: Tableau 7 - Top 'N' filter issues
              Robin Kennedy



              You cannot add a parameter on its own as a filter, but you can add a calculated field that uses that parameter at a filter and make that context...


              For example, I have a parameter called Region Parameter, and a field in my database called Region. I create a calculated field called Region Filter with the formula


              [Region] = [Region Parameter]


              This gives me a true or false field which I can now put onto the filter shelf and add to context.


              Hope that helps,