自定义列

Excel 中级 Power Query

Lyndsay Girard

Performance Analytics Consultant

M 公式语言

  • 简称"M"(Data Mashup)
  • Power Query 的函数式编程语言
  • 区分大小写
  • 内置函数丰富

编程笔记本电脑

Excel 中级 Power Query

生成 M 代码

  • 每个应用的查询步骤背后
    • 自动生成
  • 可查看 M 代码:
    • 公式栏
    • 高级编辑器

公式栏: Ch2_Formula_Bar.png

高级编辑器: Ch2_Advanced_Editor.png

Excel 中级 Power Query

自定义列

  • 用户自定义计算列
  • 使用 M 语言编写
  • 可扩展内置转换功能
    • 嵌套条件逻辑
    • 高级索引
    • 复杂计算

Ch2_Custom_Column_Ribbon_Screenshot.png

Excel 中级 Power Query

嵌套条件逻辑

  • 引用列与值
  • 可包含多层条件语句
    • If... Then... Else 语句
  • 可与逻辑运算符结合
    • AND
    • OR

基础条件逻辑

if age >= 65  
    and arrivalmode = "Car"
    then "group1"
else "group2"
Excel 中级 Power Query

嵌套条件逻辑

  • 引用列与值
  • 可包含多层条件语句
    • If... Then... Else 语句
  • 可与逻辑运算符结合
    • AND
    • OR

自定义条件逻辑

if age >= 65 and age <= 80
    and arrivalmode = "Car" 
   then "group1" 
    else if age >= 65 and age <= 80
    and arrivalmode = "ambulance" 
   then "group1a"
else "group2"
Excel 中级 Power Query

高级索引

Ch2_Before_Groupby_AllRows.png

  • 基于分组生成自定义索引或排名
Excel 中级 Power Query

高级索引

Ch2_Before_Groupby_AllRows_SimpleIndex.png

  • 基于分组生成自定义索引或排名
    • 简单索引
Excel 中级 Power Query

高级索引

Ch2_Before_Groupby_AllRows_GroupedIndex.png

  • 基于分组生成自定义索引或排名
    • 高级索引(组内)
Excel 中级 Power Query

高级索引

Ch2_GroupBy_Aggregation.png

  • 基于分组生成自定义索引或排名
  • 使用"所有行"聚合的分组操作
Excel 中级 Power Query

高级索引

Ch2_GroupBy_AllRows.png

  • 基于分组生成自定义索引或排名
  • 使用"所有行"聚合的分组操作
  • 结合自定义 M 表函数
    Table.AddIndexColumn
    
Excel 中级 Power Query

¡Vamos a practicar!

Excel 中级 Power Query

Preparing Video For Download...