1 of 1 people found this helpful
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!
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:
When I changed Region to a context filter, my data changed drastically.
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?
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.
1 of 1 people found this helpful
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.
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.
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.
Thanks! That makes sense now.