Partager via


Table.RemoveFirstN

Syntaxe

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

À propos

Retourne une table qui ne contient pas le premier nombre spécifié de lignes, countOrCondition, de la table table. Le nombre de lignes supprimées dépend du paramètre countOrConditionfacultatif.

  • S’il countOrCondition n’est omis que la première ligne est supprimée.
  • S’il countOrCondition s’agit d’un nombre, de nombreuses lignes (en commençant en haut) sont supprimées.
  • S’il countOrCondition s’agit d’une condition, les lignes qui répondent à la condition sont supprimées jusqu’à ce qu’une ligne ne réponde pas à la condition.

Exemple 1

Supprimez la première ligne du tableau.

Utilisation

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
)

Output

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

Exemple 2

Supprimez les deux premières lignes de la table.

Utilisation

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
)

Output

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

Exemple 3

Supprimez les premières lignes où [CustomerID] <=2 de la table.

Utilisation

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
)

Output

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