Additional Filtering Topics

本笔记只做复习以及巩固知识点使用,初次学习请下载练习工作簿,跟随网络课程的讲解同步操作,结果参考解法工作簿

Filtering in Tableau is incredibly powerful, but with that it can get complicated. This video assumes a basic understanding of filtering as laid out in the previous videos and goes beyond into some deeper concepts.

Context Filters

First is Context Filters. One thing to note about the filter shelf is that the filters are computed independently of each other. If a given filter will trim the data-set down, it may be worth Adding to Context. A Context Filter will be computed first, then all other filters will run only on its results.

For example, if we knew that we only wanted to look at products within the Machines sub-category, we may want to make that a context filter by right clicking and selecting “Add to Context”.

The filter is now grey, and any subsequent filters will only be on machine products. Context filters are generally best to use when they’ll return a significantly smaller set of results, the guideline is about a tenth or less of the original data.

Context filters ideally shouldn’t be something that would change frequently, so let’s hide this interactive filter.

Apply to Worksheets

When a pill is placed on the filter shelf, by default that filter applies only to the current worksheet. If it makes sense to have the filter applied more broadly, we can change the scope by clicking the pill’s drop-down choosing, “Apply to Worksheets” and applying the filter to “All using related data sources”, “All using this data source”, or “Selected worksheets”.

This can be especially useful on a Dashboard, where a filter that is relevant to multiple views can be set to apply to all or some of them simultaneously. By default, the interactive filter only applies to the view it was brought out with. But if we go to the menu and say “apply to worksheets” > “All using this data source”. Now all the views filter.

And not just the views on the dashboard. Let’s build a new sheet. We’ll double click Sales and double click Category. In the view, note that we only have one Category. But fortunately, we get this visual indication here that a filter has been applied. This icon lets you know there’s a filter on the data connection, so we can backtrack and hunt it down if that’s not what we want.

Another solution would be to say “Apply to worksheets” -> “selected worksheets” and target just the ones we want to have filter.

It’s important to note that taking an “applied to all” filter off the filter shelf removes it from all views, not just the one we’re looking at, so be careful when using this option.

Which Field to Filter On

Because we have the power to control exactly what is filtered on and how, it’s important to understand how filtering is performed. Let’s say we wanted to run a promotion for customers who purchased more than $10,000 in sales.

A straightforward way to do that might be to build a view of customers by sales, like we have here, and filter for Sales, sum is at least $10,000.

It looks right. But this summary filter of sales >$10,000 is dependent on the structure of the view. If we modify the view, we risk altering how the filter is applied. Here, we have 12 rows, indicating 12 customers eligible for our promotion. But if we break it out by Category on color, suddenly we’re down to 6 rows. Why? The 6 customers filtered out didn’t have over 10,000 in sales in a single category, even if they may have been eligible overall. Tableau ran each mark past the filter – and there’s a mark per customer per category in this view.

Alternatively, we could bring Customers to the filter shelf and use the condition tab to say we only want customers who have sales greater than 10 000. We have the same initial 12 rows,

and if we again break it out by Category we still have 12 rows. No customers were filtered out like they were last time. Here, Tableau ran Customers by their sum of sales through the filter, then any who had more than $10,000 were put into the view,bregardless of how the Categories split up those sales. Knowing how we set up our filter will impact how we can manipulate the view and maintain the filter as we designed it.

Filter Order of Operations

What order filters are put onto the filter shelf has no impact on the query sent to the data source, filters are grouped together into the WHERE clause of the query. However, filters ARE applied in a fixed order of operations.
Filters created during the Extract process limit what data is brought into the extract itself. Then, Data Source filters are applied, limiting what is made available in Tableau.

Once the data is in Tableau, Context Filters are applied first and all subsequent filters are run against their temporary table of results. Filters involving FIXED LOD expressions are evaluated next. Then filters on dimensions (like ship mode). Then INCLUDE or EXCLUDE LOD filters. Then filters on measures (like shipping cost). And finally Table Calculation filters, which are applied last (because these are performed only on the data in the view).

Performance and Filter Queries

Inefficient filtering is one of the most common causes of poorly performing workbooks and dashboards. For detailed information, see the related materials below this video. Some things to consider about filtering and its impact on performance:

Context filters are slow to create or change due to the temporary table being created behind the scenes, but once they are in place they can increase performance since further queries are only run off a subset the subset of data as opposed to the entire data set.

Cascading interactive filters can help narrow down the list of options, like here, we only see states that are in the country we selected. However, when a filter requires Tableau to find all potential field values, this requires a complex query that can take time to evaluate. Here, using a wildcard may be more performant. The presence and maintenance of indexes in the data source can dramatically improve filtering performance.

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,110评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,443评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,474评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,881评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,902评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,698评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,418评论 3 419
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,332评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,796评论 1 316
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,968评论 3 337
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,110评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,792评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,455评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,003评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,130评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,348评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,047评论 2 355

推荐阅读更多精彩内容