1

これと非常によく似た質問ですが、Power Query/M を使用しています

次の場合 (Power Query Excel インポート) ...

    A       B
1   Item    Amount
2   Item1   1
3   Item2   4
4   Grand   5

Grand で 4 行目まで (除く) すべての行を選択するにはどうすればよいですか? (およびその後のすべての行を除外)

次のような新しい列を作成しました。

#"Added Custom" = Table.AddColumn(#"Changed Type1", "match_check", each Text.Contains([A],"Grand"))

これは「Grand」行を正しく示していますが、実際に必要なのはその前のすべての行です (その後の行はありません)。

4

1 に答える 1

2

簡単だ!:))

コードを続ける:

#"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
于 2016-12-08T15:28:48.180 に答える