powerquery - 如何根据条件累积列
问题描述
我正在尝试浏览一个列表并标记父母,这样我就可以自己加入一个平面列表
ID Type Idx
200 EPIC 0
201 Feature 1
202 Feature 2
203 Feature 3
204 EPIC 4
205 Feature 5
206 Feature 6
Prefeered result
ID Type Idx Parent
200 EPIC 0 200
201 Feature 1 200
202 Feature 2 200
203 Feature 3 200
204 EPIC 4 204
205 Feature 5 204
206 Feature 6 204
我曾尝试制作自引用条件列,但那是不可能的,
#"Added Custom" = Table.AddColumn(#"Added Index", "Parent", each if [Work Item Type] = "Epic" then [ID] else #"Added Custom"{[Index]-1}[ID ]),
解决方案
添加自定义列。填写下来。假设数据在 Table1 中,有 2 列名为 ID 和 Type,则
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Parent", each if [Type]="EPIC" then [#"ID"] else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Parent"})
in #"Filled Down"
推荐阅读
- linux - 如何在centos linux上自动同步目录
- python - 如何使用 ODBC 链接 SQL 数据库并在 Python 中进行 SQL 查询
- c# - 为什么没有同时处理具有基本身份验证的 ASP.NET Web Api 请求?
- visual-studio - Visual Studio Extension 修改 Go to All 搜索结果?
- html - 背景中的图像始终位于同一位置?
- php - 以 Symfony 形式获取文件的数据
- angular - 如何在 angular4 的服务中调用管道?
- c++ - 使用矢量时 C++ 超出范围
- javascript - Javascript倒数计时器功能无法正常工作
- javascript - 如何在 Office JavaScript 加载项中调用 .NET dll?