Table.AddIndexColumn

Table.AddIndexColumn(table as table, newColumnName as text, optional initialValue as nullable number, optional increment as nullable number) as table

使用显式位置值将名为 newColumnName 的列追加到 table。 可选值 initialValue 为初始索引值。可选值 increment 指定每个索引值的增量值。

示例:

将名为 "Index" 的索引列添加到表。

使用情况:

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")

输出:

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]})

示例:

从值 10 开始、按 5 递增将名为 "index" 的索引列添加到表。

使用情况:

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)

输出:

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]})

results matching ""

    No results matching ""