powerquery m 语言 - 如何 select 所有行直到值
powerquery m language - how to select all rows until value
与 this one 非常相似的问题,但使用的是 Power Query/M
鉴于以下内容(Power Query Excel 导入)...
A B
1 Item Amount
2 Item1 1
3 Item2 4
4 Grand 5
你如何 select 直到(不包括)Grand 第四行的所有行? (并排除之后的所有行)
我创建了一个这样的新专栏:
#"Added Custom" = Table.AddColumn(#"Changed Type1", "match_check", each Text.Contains([A],"Grand"))
它正确地指示了 "Grand" 行,但真正需要的是它前面的所有行(以及它后面的 none 行)。
这很简单! :))
继续你的代码:
#"Added Custom" = Table.AddColumn(#"Changed Type1", "match_check", each Text.Contains([A],"Grand")), //Your line
AddIndex = Table.AddIndexColumn(#"Added Custom", 1, 1),
SelectGrandTotals = Table.SelectRows(AddIndex, each [match_check] = true), //select matched rows with grand totals
MinIndex = List.Min(SelectGrandTotals[Index]), //select first totals row index (if there are several such rows)
FilterTable = Table.SelectRows(AddIndex, each [Index] < MinIndex) //get all rows before
与 this one 非常相似的问题,但使用的是 Power Query/M
鉴于以下内容(Power Query Excel 导入)...
A B
1 Item Amount
2 Item1 1
3 Item2 4
4 Grand 5
你如何 select 直到(不包括)Grand 第四行的所有行? (并排除之后的所有行)
我创建了一个这样的新专栏:
#"Added Custom" = Table.AddColumn(#"Changed Type1", "match_check", each Text.Contains([A],"Grand"))
它正确地指示了 "Grand" 行,但真正需要的是它前面的所有行(以及它后面的 none 行)。
这很简单! :))
继续你的代码:
#"Added Custom" = Table.AddColumn(#"Changed Type1", "match_check", each Text.Contains([A],"Grand")), //Your line
AddIndex = Table.AddIndexColumn(#"Added Custom", 1, 1),
SelectGrandTotals = Table.SelectRows(AddIndex, each [match_check] = true), //select matched rows with grand totals
MinIndex = List.Min(SelectGrandTotals[Index]), //select first totals row index (if there are several such rows)
FilterTable = Table.SelectRows(AddIndex, each [Index] < MinIndex) //get all rows before