Bagikan melalui


Table.RemoveFirstN

Sintaks

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

Tentang

Mengembalikan tabel yang tidak berisi jumlah baris pertama yang ditentukan, countOrCondition, dari tabel table. Jumlah baris yang dihapus tergantung pada parameter countOrConditionopsional .

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

Contoh 1

Hapus baris pertama tabel.

Penggunaan

Table.RemoveFirstN(
    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 = 2, Name = "Jim", Phone = "987-6543"],
    [CustomerID = 3, Name = "Paul", Phone = "543-7890"],
    [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Contoh 2

Hapus dua baris pertama tabel.

Penggunaan

Table.RemoveFirstN(
    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"]
    }),
    2
)

Hasil

Table.FromRecords({
    [CustomerID = 3, Name = "Paul", Phone = "543-7890"],
    [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Contoh 3

Hapus baris pertama tempat [CustomerID] <=2 tabel.

Penggunaan

Table.RemoveFirstN(
    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 = 3, Name = "Paul", Phone = "543-7890"],
    [CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})