Tableau 简明教程
Tableau - Basic Filters
筛选是移除结果集中某些值或值范围的过程。Tableau 筛选功能允许使用字段值以及高级计算或基于上下文的筛选器,以适应各种情况。在本章中,您将了解 Tableau 中提供的一些基本筛选器。
Filtering is the process of removing certain values or range of values from a result set. Tableau filtering feature allows both simple scenarios using field values as well as advanced calculation or context-based filters. In this chapter, you will learn about the basic filters available in Tableau.
Tableau 中提供了三种类型的基本筛选器。它们如下所示 -
There are three types of basic filters available in Tableau. They are as follows −
-
Filter Dimensions are the filters applied on the dimension fields.
-
Filter Measures are the filters applied on the measure fields.
-
Filter Dates are the filters applied on the date fields.
Filter Dimensions
这些筛选器还应用于维度字段。典型示例包括基于文本类别的筛选或带有逻辑表达式的数值,大于或小于条件。
These filters are applied on the dimension fields. Typical examples include filtering based on categories of text or numeric values with logical expressions greater than or less than conditions.
Example
我们使用 Sample - Superstore 数据源对产品的子类别应用维度筛选器。我们创建一个视图,按配送方式显示各子类别产品的利润。为此,将维度字段“子类别”拖动到“行”架,并将度量字段“利润”拖动到“列”架。
We use the Sample - Superstore data source to apply dimension filters on the sub-category of products. We create a view for showing profit for each sub-category of products according to their shipping mode. For it, drag the dimension field “Sub-Category” to the Rows shelf and the measure field “profit” to the Columns shelf.
接下来,将“子类别”维度拖动到“筛选器”架,以打开“筛选器”对话框。单击列表底部的“无”按钮,取消选择所有细分。然后,选择对话框右下角的“排除”选项。最后,选择“标签”和“存储”,然后单击“确定”。以下屏幕截图显示了上述两个类别被排除后的结果。
Next, drag the Sub-Category dimension to the Filters shelf to open the Filter dialog box. Click the None button at the bottom of the list to deselect all segments. Then, select the Exclude option in the lower right corner of the dialog box. Finally, select Labels and Storage and then click OK. The following screenshot shows the result with the above two categories excluded.
Filter Measures
这些筛选器应用于度量字段。筛选基于应用于度量字段的计算。因此,虽然在维度筛选器中您只使用值进行筛选,而在度量筛选器中则使用基于字段的计算。
These filters are applied on the measure fields. Filtering is based on the calculations applied to the measure fields. Hence, while in dimension filters you use only values to filter, in measures filter you use calculations based on fields.
Example
您可以使用 Sample - Superstore 数据源对利润平均值应用维度筛选器。首先,创建一个视图,其中配送方式和子类别作为维度,利润平均值如下图所示。
You can use the Sample - Superstore data source to apply dimension filters on the average value of the profits. First, create a view with ship mode and subcategory as dimensions and Average of profit as shown in the following screenshot.
接下来,将“平均值(利润)”值拖动到筛选器窗格。选择“平均值”作为筛选器模式。接下来,选择“至少”,并给出筛选满足这些条件的行的一个值。
Next, drag the AVG (profit) value to the filter pane. Choose Average as the filter mode. Next, choose "At least" and give a value to filter the rows, which meet these criteria.
完成上述步骤后,我们得到了最后的视图,其中只显示了平均利润大于 20 的子类别。
After completion of the above steps, we get the final view below showing only the subcategories whose average profit is greater than 20.
Filter Dates
Tableau 在应用日期字段时以三种方式处理日期字段。它可以通过采用与今天比较的相对日期、绝对日期或日期范围来应用筛选器。当将日期字段从筛选器窗格拖出时,会显示这每个选项。
Tableau treats the date field in three different ways while applying the date field. It can apply filter by taking a relative date as compared to today, an absolute date, or range of dates. Each of this option is presented when a date field is dragged out of the filter pane.
Example
我们选择 sample - Superstore 数据源,并创建一个视图,其中订单日期在列架中,利润在行架中,如下图所示。
We choose the sample - Superstore data source and create a view with order date in the column shelf and profit in the rows shelf as shown in the following screenshot.
接下来,将“订单日期”字段拖动到筛选器架上,然后在筛选器对话框中选择“日期范围”。按以下屏幕截图中的方式选择日期。
Next, drag the "order date" field to the filter shelf and choose Range of dates in the filter dialog box. Choose the dates as shown in the following screenshot.
单击“确定”后,将显示包含已选择日期范围的结果的最终视图,如下图所示。
On clicking OK, the final view appears showing the result for the chosen range of dates as seen in the following screenshot.