筛选工具
单个工具示例
“筛选”具有一个单个工具示例。访问 示例工作流 以了解如何在 Alteryx Designer 中访问此示例和其他更多示例。
使用“筛选”工具根据条件选择数据。符合条件的数据行会输出至 True 锚点。不符合条件的数据行会输出到 False 锚点。
筛选工具可以...
工具组件
![Screenshot of the filter tool on the Designer canvas](../../../image/uuid-707d5917-a4eb-8d79-61aa-02f0c79da026.png)
筛选工具有 3 个以上的锚点。
输入锚点:使用输入锚点选择要筛选的数据。
T (True)锚点:True 锚点输出满足筛选条件的数据行。
F (False)锚点:False 锚点输出不满足筛选条件的数据行。
*由于筛选工具包括表达式编辑器,因此在应用或宏中使用它时,筛选工具会出现一个额外的输入锚点。使用 “界面”工具 连接到“问题”锚点。
配置工具
选择 基本筛选器 或 自定义筛选器 。
使用 基本筛选器 对单个数据列创建简单的查询。
使用 自定义筛选器 使用一个或多个列创建复杂的条件。
![Screenshot of Filter configuration window with options to select Basic filter or Custom filter.](../../../image/uuid-c281e041-43ec-2cc9-4e3c-dcc64754572c.png)
构建基本筛选器
在 选择列 下拉列表中选择要进行数据筛选的列。
在下一下拉列表中选择运算符。可用的运算符取决于所选筛选列的数据类型。参考以下 基本筛选器运算符 。
输入一个值以完成条件。
基本筛选器
可用的运算符取决于所选筛选列的数据类型。了解更多有关 数据类型 的信息。
运算符 | 描述 | 可用数据类型 |
---|---|---|
= | 值与输入相匹配。 | 数值、日期、日期时间 |
等于 | 值与输入相匹配。 | 字符串 |
!= | 值与输入不相匹配。 | 数值、日期、日期时间 |
不等于 | 值与输入不相匹配。 | 字符串 |
> | 值大于输入。 | 数值、日期、日期时间 |
>= | 值大于或等于输入。 | 数值、日期、日期时间 |
< | 值小于输入。 | 数值、日期、日期时间 |
<= | 值小于或等于输入。 | 数值、日期、日期时间 |
为 null | 缺失或未知的值。 | 数值, 日期, 日期时间, 时间, 字符串, 空间, 布尔值 |
不为 null | 非缺失或未知的值。 | 数值, 日期, 日期时间, 时间, 字符串, 空间, 布尔值 |
之前 (<) | 经排序的值在输入之前。 | 字符串 |
之后 (>) | 经排序的值在输入之后。 | 字符串 |
包含 | 值可以存在于字符串中任何部分。 | 字符串 |
不包含 | 在字符串的任何部分都找不到值(区分大小写)。 | 字符串 |
为空 | 为 Null 或 "" 的值 | 字符串 |
不为空 | 非 Null 或"" 的值 | 字符串 |
范围 | 值是一个选定的开始和结束日期。 | 日期,日期时间 |
开始日期和之后的区间 | 值是选定的第一个日期和随后的期间数。 | 日期,日期时间 |
结束日期和之前的区间 | 值是选择的最后日期和之前的设定的周期数。 | 日期,日期时间 |
为 True | 值为 true。 | 布尔值 |
为 false | 值不为 True。 | 布尔值 |
使用表达式构建自定义筛选器
要构建一个自定义筛选条件,请在表达式编辑器中输入表达式语法。还有许多工具可以帮助构建自定义筛选条件。查看 表达式编辑器提示 。
![Screenshot of a Custom filter setup](../../../image/uuid-d525f506-2dcb-17f5-1234-f0163c40fa38.png)
表达式编辑器提示
使用以下表达式编辑器中的按钮,帮助构建自定义筛选条件。
保存自定义筛选
生成表达式后,可以将其保存以供以后使用。选择 保存 图标。输入表达式名称并选择 保存 。
工具示例
示例 1.使用基本比较选择行
使用基本筛选器通过将列与静态值进行比较来选择行。
![Screenshot of a Basic filter setup](../../../image/uuid-aac7ff4d-8109-868f-cfe4-9735c5c63207.png)
根据上述基本筛选器的条件,CustomerID 值大于 30 的行将输出到 True 锚点。
![Screenshot of the True anchor results which includes all rows where CustomerID is greater than 30](../../../image/uuid-6dd3e912-6867-aaa8-7d73-2ce6bfb1e30e.png)
CustomerID 值不大于 30 的行将输出到 False 锚点。
![Screenshot of the False anchor results which includes all rows where CustomerID is not greater than 30](../../../image/uuid-d5e3f2aa-1145-cc2d-b26b-97215797b9b3.png)
示例 2.选择存在或不存在丢失数据的行
使用基本筛选器选择无缺失数据的行。
![Use the Basic filter to select records without missing data.](../../../image/uuid-f58e2a02-3e88-f969-618e-6e6ea943148c.png)
根据上述基本筛选器的条件,“LastName” 值不为 Null(缺失)的行将输出到 True 锚点。
![Rows with a LastName that is not null (missing) are output to the True anchor.](../../../image/uuid-b014be4b-6136-091b-cb84-b5bb721ca4bc.png)
“LastName” 值为 Null 的行将输出到 False 锚点。
![Screenshot of the False anchor results which shows all rows with a null value in LastName](../../../image/uuid-1df222f5-7926-0445-1779-fbda1fd6438e.png)
示例 3.使用日期时间数据选择行
使用基本筛选器根据相对日期选择行。
![Screenshot of a Basic filter with the condition JoinDate is less than or equal to todaye.](../../../image/uuid-f5be1b0d-9f4c-9d9b-8831-9b37b1343c26.png)
根据上述基本筛选器的条件, JoinDate 小于或等于今天的行将输出到 True 锚点。
![Screenshot of True anchor results which shows rows with a JoinDate that is less than or equal to today's date](../../../image/uuid-cb92d6f9-99f9-c211-cba4-c9b53e1eb4e7.png)
具有今天之后的日期的行将输出到 False 锚点。
![Screenshot of False anchor results which shows rows with a JoinDate after today's date](../../../image/uuid-084d5786-40dc-c7d5-ff49-be0288c025f2.png)
日期时间筛选器提示
动态选项(今天、明天和昨天)在运行工作流时会将工作流的日期更新到对应的当前日期。
开始日期以及此后的周期内 或 结束日期以及此前的周期内 运算符允许您通过选择特定的日期、 周期类型 (天、月、周、季度或年)以及之前或之后的 周期数 来指定日期范围。
选择 仅筛选日期数据 将截断日期时间数据,并仅使用日期数据。
示例 4.使用多列条件选择行
使用自定义筛选器创建使用多个列选择行的条件。
![Screenshot of a custom filter with the condition JoinDate is greater than or equal to the FirstPurchaseDate](../../../image/uuid-e2c59cd2-3d8c-6c38-5f7b-377112ae5cc3.png)
根据上述自定义筛选器的条件,JoinDate 大于或等于 FirstPurchaseDate 的行将输出到 True 锚点。
![Screenshot of the True anchor results which shows rows with a JoinDate that is greater than or equal to the FirstPurchaseDate](../../../image/uuid-a1f17ff4-09ad-40fa-60ce-ad3b4ee8ab22.png)
JoinDate 小于 FirstPurchaseDate 的行将输出到 False 锚点。在这种情况下,不存在 JoinDate 比 FirstPurchaseDate 更早的行。
示例 5.使用复合条件选择行
使用自定义筛选器创建复合条件,即由和/或运算符连接多个条件。
![Screenshot of a Custom filter with the condition where the region is either South or contains the word West](../../../image/uuid-7e7a9c7c-7718-b0cc-5aa6-594adf629ec3.png)
根据上述自定义筛选器的条件,Region 为 South 或包含 “West” 字的行将输出到 True 锚点。
![Screenshot of the True anchor results which shows rows where the region is either South or contains the word West](../../../image/uuid-27775085-d906-13a7-9d64-649b0758dad3.png)
所有其他行都输出到 False 锚点。
![Screenshot of the False anchor results which shows all rows where region is not South and does not contain the word West](../../../image/uuid-1dc5d917-625c-a101-54e6-8f16a82facde.png)
疑难解答
使用字符串处理超过 15 位的数字以防止精度损失。您可以使用 "选择工具 "将字段类型设置为字符串。