Bagikan melalui


Table.RemoveLastN

Sintaks

Table.RemoveLastN(table as table, optional countOrCondition as any) as table

Tentang

Mengembalikan tabel yang tidak berisi baris terakhir countOrCondition tabel table. Jumlah baris yang dihapus tergantung pada parameter countOrConditionopsional .

  • Jika countOrCondition dihilangkan hanya baris terakhir yang dihapus.
  • Jika countOrCondition adalah angka, banyak baris (dimulai di bagian bawah) akan dihapus.
  • Jika countOrCondition adalah kondisi, baris yang memenuhi kondisi akan dihapus hingga baris tidak memenuhi kondisi.

Contoh 1

Hapus baris terakhir tabel.

Penggunaan

Table.RemoveLastN(
    Table.FromRecords({
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"],
        [CustomerID = 3, Name = "Paul", Phone = "543-7890"],
        [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
    }),
    1
)

Hasil

Table.FromRecords({
    [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
    [CustomerID = 2, Name = "Jim", Phone = "987-6543"],
    [CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Contoh 2

Hapus baris terakhir tempat [CustomerID] > 2 tabel.

Penggunaan

Table.RemoveLastN(
    Table.FromRecords({
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"],
        [CustomerID = 3, Name = "Paul", Phone = "543-7890"],
        [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
    }),
    each [CustomerID] >= 2
)

Hasil

Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})