如何根据条件累积列
How to accumulate a column based on a condition
我正在尝试浏览一个列表并标记 parents 这样我就可以自己加入一个平面列表
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
我尝试制作 self-referencing 条件列,但那是不可能的,
#"Added Custom" = Table.AddColumn(#"Added Index", "Parent", each if [Work Item Type] = "Epic" then [ID] else # "Added Custom"{[索引]-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"
我正在尝试浏览一个列表并标记 parents 这样我就可以自己加入一个平面列表
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
我尝试制作 self-referencing 条件列,但那是不可能的,
#"Added Custom" = Table.AddColumn(#"Added Index", "Parent", each if [Work Item Type] = "Epic" then [ID] else # "Added Custom"{[索引]-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"