8 Replies Latest reply on Sep 28, 2016 1:45 PM by heather.vogt

    What's the value in using a context filter?


      Hello! I am doing some research on context filters and found this and this. While these tell me how to make a context filter, I don't see any value in using them.


      Using the first resource's example, I tried the Category context filter and didn't really see any value in using a context filter when just dragging the Sub-category pill behind the Category pill in the Rows shelf does the same thing. Also, there isn't really a lot of data to filter down anyway; there are only like 15 sub-categories.


      The second resource, the video, seems a little better because you whittle Product ID-Profit data down considerably. However, the data is whittled down using the Sub-category: Machines quick filter. Changing this to a context filter doesn't change anything about the data.


      I get you're supposed to use context filters when it can successfully pare data down to 1/10th its size, but I haven't found anything that authentically demonstrates the value of a context filter.


      Can someone point me in the direction of an authentic application of context filters? One that shows what they're actually capable of?


      Many thanks!

        • 1. Re: What's the value in using a context filter?
          Joshua Milligan



          Context filters give you a subset of data that is used as the context for certain features of Tableau:

          • Top/Bottom N Filters - e.g. Give me the top 10 customers overall (no context) or within the filtered region (Region made a context filter)
          • Computed Sets - similar to above
          • FIXED Level of Detail expressions - e.g. Give me the minimum price per product overall (no context) or within the selected year (Year filter made part of the context)


          Additionally, context filters might improve performance in some circumstances. They used to create temporary tables and while you'd take a performance hit while the temp table was created, all subsequent calculations would be done on the temp table, which if it was significantly smaller than the initial data set might dramatically improve performance.  It's my understanding that temp tables are no longer used, but it is conceivable that you might, in some cases, still see a performance gain with context filters.  But I wouldn't spend a lot of time trying to tune performance based on context filters unless you just happen to find that a given context filter gives you a perceivable boost.  Otherwise, just use them to control the behavior of Tableau for Top/Bottom Filters, Sets and FIXED LOD.


          Hope the helps!


          1 of 1 people found this helpful
          • 2. Re: What's the value in using a context filter?

            Hello, Joshua Milligan


            So I used your Top/Bottom N Filters idea to create a viz for the top 10 customers in Asia and created this:


            Easy, right?


            When I changed Region to a context filter, my data changed drastically.


            9-28 two.png

            I guess that's the point, but why did it change? In the shot above I am first filtering on Region and then I'm filtering for top 10 customers by Sales. These people are completely different than the first shot, and the only change is Region is now a context filter. Why are these people completely different?


            I was thinking the first shot showed the intersection of the two filters--top 10 customers in these specific regions, and the second filtered first on Region and then filtered for the top 10 based on that region. Isn't that the same thing? How are completely different people? What am I missing?

            • 3. Re: What's the value in using a context filter?

              Joshua Milligan


              Is the first, uncontextualized Region filter applying the Region filter to the top 10 customers, while the second, contextualized Region filter is first going by Region and then to the top 10?


              That seems to be the case (and the whole point of context filters), but the two seem to be doing the exact same thing; I'm just getting different customer names. That has to be because of the context filter (that's the only difference between the two sheets), but I don't understand WHY or HOW these work. I'm trying to explain this to students; I don't want to just say, "That's just how it works." Teaching fail.


              Attached is the workbook. I am asking about the last two sheets--no context and context.



              • 5. Re: What's the value in using a context filter?
                Ivan Young

                Hi Heather,

                Check out this link to Tableau's Order of Operations.  It should provide more context to the context filter.  The reason you are seeing a change in your Top N results when you add your filter to context is because context filters are applied prior to Top N filters whereas normal Dimension filters are applied after Top N filters.




                Tableau's Order of Operations

                1 of 1 people found this helpful
                • 6. Re: What's the value in using a context filter?

                  Hello, Ivan!


                  The resources I've been using mention that when a context filter is used, it is the first point of contact for any data that needs to be filtered. Any filters added to the Filters shelf will then filter based on that context-filtered data. From what I can gather from what you sent me, this is because of Tableau's Order of Operations.


                  So, like I said to Joshua, the decontextualized, normal Region filter and the Customer Name Top 10 filter are working to spit out a viz displaying the intersection of the filters, correct? So I'm seeing data of the top 10 customers with a Region filter rather than a Region filter with its top 10 customers?  Is there an order to how decontextualized, normal Dimension filters are applied, or do they all reach the finish line together and spit something out?


                  According to what you sent me, however, (thanks by the way) the contextualized Region filter is applied first. Then, the regular old Dimension filter, Customer Name, is applied second.



                  • 7. Re: What's the value in using a context filter?
                    Joshua Milligan



                    Yes. In your first view, you are seeing the top 10 customers overall with SUM(Sales) being add per customer based on the filters.  So if a filter reduces the sales for that person, you'll see the value change -- but you'll always see those 10 customers (or maybe less if the combination of filters ends up excluding them completely).


                    In the second view, with Region on context, you are seeing the top 10 customers within the included Regions.  Other dimension filters might change the values in the same way as in the first view (or even exclude some of the customers completely -- in which case you may see less than 10), but the overall list of 10 is based on the context.


                    Best Regards,


                    • 8. Re: What's the value in using a context filter?

                      Thanks! That makes sense now.