Table.AddIndexColumn
Fügt eine Spalte mit expliziten Positionswerten an.
Syntax
Table.AddIndexColumn(
table as table,
newColumnName as text,
optional initialValue as number,
optional increment as number,
optional columnType as type
) as table
Remarks
Fügt "table
" eine Spalte namens "newColumnName
" mit expliziten Positionswerten an. Der Ausgangsindex kann mithilfe des optionalen Werts "initialValue
" angegeben werden. Die gewünschte Schrittweite für die einzelnen Indexwerte kann mithilfe des optionalen Werts "increment
" angegeben werden.
Examples
Example #1
Fügt der Tabelle eine Indexspalte namens "Index" hinzu.
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"
)
Result:
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]
})
Example #2
Fügt der Tabelle eine Indexspalte namens "index" hinzu, die bei 10 beginnt und um 5 inkrementiert wird.
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
)
Result:
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]
})
Category
Table.Transformation