แชร์ผ่าน


Table.AddKey

วากยสัมพันธ์

Table.AddKey(
    table as table,
    columns as list,
    isPrimary as logical
) as table

ประมาณ

เพิ่มคีย์ลงใน tableโดยที่ columns คือรายการของชื่อคอลัมน์ที่กําหนดคีย์ และ isPrimary จะระบุว่าคีย์เป็นคีย์หลักหรือไม่

ตัวอย่างที่ 1

เพิ่มคีย์หลักแบบคอลัมน์เดียวลงในตาราง

การใช้งาน

let
    table = Table.FromRecords({
        [Id = 1, Name = "Hello There"],
        [Id = 2, Name = "Good Bye"]
    }),
    resultTable = Table.AddKey(table, {"Id"}, true)
in
    resultTable

ผลลัพธ์ของ

Table.FromRecords({
    [Id = 1, Name = "Hello There"],
    [Id = 2, Name = "Good Bye"]
})