Table.AddIndexColumn
Syntaxe
Table.AddIndexColumn(table as table, newColumnName as text, optional initialValue as nullable number, optional increment as nullable number, optional columnType as nullable type) as table
À propos
Ajoute une colonne nommée newColumnName
à la table
avec des valeurs de position explicites. Une valeur facultative, initialValue
, spécifie la valeur d’index initiale. Une valeur facultative, increment
, spécifie l’incrément de chaque valeur d’index.
Exemple 1
Ajoute une colonne d’index nommée « Index » à la table.
Utilisation
Table.AddIndexColumn(
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"]
}),
"Index"
)
Sortie
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", Index = 0],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", Index = 1],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", Index = 2],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550", Index = 3]
})
Exemple 2
Ajoute une colonne d’index nommée « Index » à la table, en commençant à la valeur 10 et en incrémentant par 5.
Utilisation
Table.AddIndexColumn(
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"]
}),
"Index",
10,
5
)
Sortie
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", Index = 10],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", Index = 15],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", Index = 20],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550", Index = 25]
})