Table.RemoveLastN

Składnia

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

Informacje

Zwraca tabelę, która nie zawiera ostatnich countOrCondition wierszy tabeli table. Liczba usuniętych wierszy zależy od opcjonalnego parametru countOrCondition.

  • Jeśli countOrCondition pominięto tylko ostatni wiersz, zostanie usunięty.
  • Jeśli countOrCondition jest liczbą, zostanie usuniętych wiele wierszy (zaczynających się od dołu).
  • Jeśli countOrCondition jest warunkiem, wiersze spełniające warunek zostaną usunięte, dopóki wiersz nie spełnia warunku.

Przykład 1

Usuń ostatni wiersz tabeli.

Użycie

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
)

Wyjście

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

Przykład 2

Usuń ostatnie wiersze, w których [CustomerID] > 2 tabeli.

Użycie

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
)

Wyjście

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