条件函数

Alteryx 中的数据转换

Josh Honken

Senior Associate at Knowesis

课程概览与欢迎

数据转换图标

  • 第1章:Formula 工具
  • 第2章:Transpose 工具
  • 第3章:Cross Tab 工具
Alteryx 中的数据转换

Formula 工具

Alteryx 中 Formula 工具的蓝色图标,含实验室烧瓶

  • 新建列
  • 更新列
  • 进行计算与操作

$$ $$ $$ 您可以用它来:

  • 应用条件语句
  • 格式化日期
  • 应用数学计算
Alteryx 中的数据转换

函数与运算符

条件函数:按条件测试数据

  • IFELSEIF
  • IIF

逻辑运算符:组合语句,提高复杂度

  • AND (&&)
  • OR (||)
  • NOT (!)
Alteryx 中的数据转换

IF 语句

  • 语法:IF c THEN t ELSE f ENDIF
  • 若条件 c 为真,返回 t,否则返回 f

美国地图,轻微高亮这四个州

Alteryx 中的数据转换

IF 语句

  • 语法:IF c THEN t ELSE f ENDIF
  • 若条件 c 为真,返回 t,否则返回 f

$$

State Region
Texas
California
Indiana
New York

美国地图,轻微高亮这四个州

Alteryx 中的数据转换

IF 语句

  • 语法:IF c THEN t ELSE f ENDIF
  • 若条件 c 为真,返回 t,否则返回 f
  • IF [State] = 'TX' THEN 'South' ELSE 'Not South' ENDIF $$
State Region
Texas South
California Not South
Indiana Not South
New York Not South

美国地图,高亮德州

legend.png

Alteryx 中的数据转换

IIF 函数

  • 若布尔值为真返回 x,否则返回 y
  • 语法:IIF(bool, x, y)
  • IIF([State] = 'TX', 'South', 'Not South'

$$

State Region
Texas South
California Not South
Indiana Not South
New York Not South

美国地图,高亮德州

legend.png

Alteryx 中的数据转换

ELSEIF 语句

  • 若首个条件 c 为真,返回 t
  • 否则若第二个条件 c2 为真,返回 t2
  • 否则返回 f

IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF

IF [State] = 'TX' THEN 'South' ELSEIF [State] = 'CA' THEN 'West' ELSE 'Other' ENDIF

State Region
Texas South
California West
Indiana Other
New York Other

elseifmap.png

Alteryx 中的数据转换

IF 中的多条件

  • AND (&&):两条件都为真时为真
  • OR (||):任一条件为真时为真
  • NOT (!):条件为假时为真

IF [State]='Texas' AND [City]='Dallas' OR [State]='Texas' AND [City]='Fort Worth' THEN 'Dallas Fort Worth' $$ ELSE 'No match' ENDIF

State City Dallas Texas?
Texas Dallas Dallas Fort Worth
Arkansas Dallas 城市匹配但州不匹配
Texas Fort Worth Dallas Fort Worth
California San Francisco 不匹配
Alteryx 中的数据转换

CONTAINS()

  • CONTAINS(String, Target)
  • CONTAINS([Customer Name],'z')
Customer Name
Claire Gute
Sean O'Donnell
Pete Kriz
Zachary Taylor
Alteryx 中的数据转换

CONTAINS()

  • CONTAINS(String, Target)
  • CONTAINS([Customer Name],'z')
Customer Name Contains Z?
Claire Gute 0
Sean O'Donnell 0
Pete Kriz -1
Zachary Taylor -1
Alteryx 中的数据转换

我们的数据集

本课程数据集:Genesis_LLC_Company_HR_Data.xlsx

Age Attrition BusinessTravel DailyRate
51 0 -1 684
52 0 0 699
42 0 0 532
47 0 0 359

本课程使用的虚拟公司 Genesis 研发 的标志

Alteryx 中的数据转换

Ayo berlatih!

Alteryx 中的数据转换

Preparing Video For Download...