Condividi tramite


Table.RemoveLastN

Sintassi

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

Informazioni su

Restituisce una tabella che non contiene le ultime countOrCondition righe della tabella table. Il numero di righe rimosse dipende dal parametro countOrCondition facoltativo.

  • Se countOrCondition viene omesso, verrà rimossa solo l'ultima riga.
  • Se countOrCondition è un numero, verrà rimosso lo stesso numero di righe, a partire dal basso.
  • Se countOrCondition è una condizione, verranno rimosse le righe che soddisfano la condizione finché non viene trovata una riga che non soddisfa la condizione.

Esempio 1

Rimuovere l'ultima riga della tabella.

Utilizzo

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
)

Output

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

Esempio 2

Rimuovere le ultime righe in cui [CustomerID] > 2 della tabella.

Utilizzo

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
)

Output

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