Sql.Databases ใช้สำหรับการประมวลผล
Syntax
sql_databases(value as any) as any
Sql.Databases ใช้สำหรับการประมวลผล
sql_databases(value as any) as any
SqlExpression.SchemaFrom ใช้สำหรับการประมวลผล
sqlexpression_schemafrom(value as any) as any
SqlExpression.ToExpression ใช้สำหรับการประมวลผล
sqlexpression_toexpression(value as any) as any
Sybase.Database ใช้สำหรับการประมวลผล
sybase_database(value as any) as any
Table.AddColumn เพิ่มคอลัมน์ใหม่ลงในตารางโดยคำนวณค่าจากฟังก์ชันที่กำหนด ใช้คำสั่ง each เพื่ออ้างอิงข้อมูลในแต่ละแถว เช่น each [Price] * [Quantity] สามารถระบุชนิดข้อมูลได้เพื่อเพิ่มประสิทธิภาพและป้องกันข้อผิดพลาดจากการคาดเดาชนิดข้อมูล ทำงานแบบทีละแถวและเหมาะสำหรับสร้างคอลัมน์คำนวณ รวมข้อมูล ใช้เงื่อนไข และการแปลงข้อมูลต่างๆ ใช้ร่วมกับฟังก์ชัน Table.TransformColumns สำหรับแก้ไขคอลัมน์เดิม Table.AddIndexColumn สำหรับเพิ่มหมายเลขลำดับ Table.SelectRows สำหรับกรองแถว Table.FromRecords สำหรับสร้างตารางจากข้อมูล Text.Combine สำหรับรวมข้อความ Number.Round สำหรับปัดเศษ Date.Year สำหรับดึงค่าปี และ Text.Upper สำหรับแปลงเป็นตัวพิมพ์ใหญ่ เพื่อสร้างกระบวนการแปลงข้อมูลที่สมบูรณ์
Table.AddColumn(table as table, newColumnName as text, columnGenerator as function, optional columnType as nullable type) as table
Table.AddFuzzyClusterColumn เพิ่มคอลัมน์ใหม่ที่มีค่าตัวแทนสำหรับแต่ละกลุ่ม โดยจับคู่ข้อมูลที่คล้ายกัน แม้จะมีข้อความที่ต่างกัน เช่น การสะกด ตัวอักษรพิมพ์ใหญ่-เล็ก หรือช่องว่าง
= Table.AddFuzzyClusterColumn(table as table, columnName as text, newColumnName as text, optional options as nullable record) as table
Table.AddIndexColumn ใช้สำหรับเพิ่มคอลัมน์ที่มีลำดับเลขให้กับตาราง ช่วยให้สามารถกำหนดหมายเลขแถวตามลำดับได้
Table.AddIndexColumn(table, newColumnName, [initialValue], [increment], [columnType])
Table.AddJoinColumn เชื่อมต่อข้อมูลจากสองตารางตามคีย์ที่ตรงกัน โดยเก็บผลลัพธ์ในคอลัมน์ใหม่เป็นตารางแบบ nested แทนการขยายแนวนอน
= Table.AddJoinColumn(table1, key1, table2, key2, newColumnName)
Table.AddMatchColumn เพิ่มคอลัมน์ใหม่ที่มีค่าจากการแมตช์แถวในตารางอื่น โดยค้นหาค่าที่ตรงกับคีย์ เหมือน VLOOKUP แต่ทำงานโดยตรงบนตารางทั้งหมด
Table.AddMatchColumn(table as table, newColumnName as text, tableColumnPairs as list, optional joinKind as JoinKind) as table
Table.Buffer บังคับโหลดตารางลงหน่วยความจำและแยกออกจากแหล่งข้อมูลต้นทาง ช่วยป้องกันการ fold และควบคุมเวลาประมวลผล
= Table.Buffer(table as table, optional options as nullable record) as table
โหลดตารางเข้าสู่หน่วยความจำ (RAM) เพื่อแยกข้อมูลจากแหล่งเดิมและป้องกันไม่ให้ Query Folding ดึงข้อมูลใหม่
Table.Buffer(table as table, optional options as nullable record) as table
Table.Column ดึงค่าจากคอลัมน์เฉพาะออกมาจากตาราง และคืนค่าเป็น List เพื่อให้สามารถนำไปประมวลผลต่อได้
= Table.Column(table as table, columnName as text) as list
Table.ColumnCount ใช้สำหรับการประมวลผล
table_columncount(value as any) as any
Table.ColumnNames ดึงชื่อคอลัมน์ทั้งหมดจากตาราง และส่งกลับมาเป็นลิสต์ข้อความ ซึ่งจำเป็นสำหรับการตรวจสอบ schema แบบ dynamic
= Table.ColumnNames(table as table) as list
Table.ColumnNames ดึงชื่อคอลัมน์ทั้งหมดจากตารางและคืนค่าเป็นลิสต์ของข้อความ เหมาะสำหรับการทำงานแบบไดนามิกกับโครงสร้างตารางที่ไม่แน่นอน
= Table.ColumnNames(table as table) as list
Table.Combine ใช้สำหรับรวม list ของ table เข้าเป็น table เดียว ยับยั้ง append ตัว 1 แถวหลาย ๆ ตารางพร้อมกัน
Table.Combine(tables as list, optional columns as any) as table
Table.CombineColumns รวมข้อมูลจากหลายคอลัมน์เข้าด้วยกันเป็นคอลัมน์เดียว โดยใช้ฟังก์ชัน Combiner ที่กำหนดเอง เช่น รวมชื่อ-นามสกุล หรือสร้างรหัสประจำตัว
Table.CombineColumns(table as table, sourceColumns as list, combiner as function, newColumnName as text) as table
Table.ConformToPageReader ปรับโครงสร้างตารางให้เข้ากับกลไก page reader โดยรับฟังก์ชันสำหรับการจัดรูปแบบ เป็นฟังก์ชันภายในของ Power Query ไม่แนะนำให้ใช้ในโค้ดทั่วไป
Table.ConformToPageReader(table as table, shapingFunction as function) as table
ตรวจสอบว่า List ของ Record ที่ระบุ ปรากฏอยู่ในตารางข้อมูลครบทุกตัวหรือไม่ (เป็น Subset หรือไม่) โดยสามารถกำหนดคอลัมน์ที่ใช้เปรียบเทียบได้
Table.ContainsAll(table as table, rows as list, optional equationCriteria as any) as logical
ตรวจสอบว่ามี Record จาก List ที่ระบุ ปรากฏอยู่ในตารางอย่างน้อย 1 ตัวหรือไม่ (Intersection ไม่ว่างเปล่า) โดยสามารถกำหนดคอลัมน์ที่ใช้เปรียบเทียบได้
Table.ContainsAny(table as table, rows as list, optional equationCriteria as any) as logical
Table.Distinct ลบแถวที่ซ้ำกันออกจากตารางตามคอลัมน์ที่กำหนด หรือทั้งตารางถ้าไม่ระบุคอลัมน์
Table.Distinct(table as table, optional equationCriteria as any) as table
สร้างคอลัมน์ใหม่โดยคัดลอกค่ามาจากคอลัมน์ที่มีอยู่เดิม (Duplicate)
Table.DuplicateColumn(table as table, columnName as text, newColumnName as text, optional columnType as nullable type) as table
Table.ExpandListColumn ใช้สำหรับขยายคอลัมน์ที่เก็บข้อมูลแบบ List ให้เป็นแถวแยก โดยแต่ละรายการใน List จะกลายเป็นแถวใหม่ ส่วนข้อมูลในคอลัมน์อื่นจะถูกทำซ้ำตามจำนวน
Table.ExpandListColumn(table as table, column as text) as table
Table.ExpandRecordColumn ขยายคอลัมน์ที่เก็บ Record values ออกเป็นคอลัมน์แยกกัน โดยแต่ละฟิลด์ใน Record จะกลายเป็นคอลัมน์ใหม่ สามารถระบุว่าต้องการขยายฟิลด์ใดบ้างผ่าน fieldNames parameter และสามารถกำหนดชื่อคอลัมน์ใหม่ผ่าน newColumnNames เพื่อป้องกันชื่อซ้ำ มักใช้หลังจาก API calls หรือการ parse JSON ที่ได้ข้อมูลแบบ nested
Table.ExpandRecordColumn(table as table, column as text, fieldNames as list, optional newColumnNames as nullable list) as table
Table.ExpandTableColumn ใช้แตกข้อมูลจากคอลัมน์ที่เป็น nested table ออกมาเป็นคอลัมน์และแถวปกติในตารางหลัก โดยรักษาข้อมูลคอลัมน์อื่นไว้ และทำซ้ำแถวหลักสำหรับแต่ละแถวในตารางซ้อน มักใช้คู่กับ Table.NestedJoin หลัง join ตาราง หรือใช้ขยายข้อมูลจากแหล่งที่มีโครงสร้างแบบ hierarchical เช่น JSON หรือ API
Table.ExpandTableColumn(table as table, column as text, columnNames as list, optional newColumnNames as nullable list) as table
Table.FillDown เติมเต็มค่า null ด้วยค่าจากแถวด้านบน (forward fill) เหมาะสำหรับข้อมูลที่มีการ merge cell หรือจัดกลุ่มข้อมูลแบบ hierarchical ทำให้ได้ตารางที่สมบูรณ์พร้อมใช้ต่อได้เลย
= Table.FillDown(table as table, columns as list) as table
Table.FillUp เติมเต็มค่าว่าง (null) ด้วยค่าจากแถวด้านล่างขึ้นไป ทำงานตรงกันข้ามกับ FillDown ใช้สำหรับจัดการข้อมูลที่ค่าสรุปอยู่ล่างสุด
Table.FillUp(table as table, columns as list) as table
ดึงแถวแรก (Record) จากตารางข้อมูล พร้อมตัวเลือกค่า default สำหรับกรณีตารางว่าง
Table.First(table as table, optional default as any) as any
Table.FirstN คืนแถวแรกๆ จากตาราง โดยสามารถระบุจำนวนแถวที่ต้องการ หรือระบุเงื่อนไข (condition function) เพื่อดึงแถวที่ตรงเงื่อนไขจนกว่าจะพบแถวที่ไม่ตรงแล้วหยุด ถ้าส่งเป็นตัวเลข เช่น 5 จะได้ 5 แถวแรก ถ้าส่งเป็นฟังก์ชัน เช่น each [Amount] > 0 จะได้แถวที่ Amount > 0 จนกว่าจะเจอแถวที่ Amount ≤ 0
Table.FirstN(table as table, countOrCondition as any) as table
Table.FromColumns สร้างตารางจากลิสต์ของลิสต์ โดยแต่ละลิสต์จะเป็นคอลัมน์หนึ่ง เหมาะกับข้อมูล column-oriented จาก API หรือ JSON
Table.FromColumns(lists as list, optional columns as any) as table
แปลง List เป็น Table โดยใช้ฟังก์ชัน Splitter เพื่อแยกข้อมูลเป็นคอลัมน์
= Table.FromList(list as list, optional splitter as nullable function, optional columns as any, optional default as any, optional extraValues as nullable number) as table
แปลง List ของ Record เป็นตาราง โดยแต่ละ Record กลายเป็นหนึ่งแถว เหมาะสำหรับข้อมูลจาก API หรือ JSON
Table.FromRecords(records as list, optional columns as any, optional missingField as nullable number) as table
Table.FromRows สร้างตารางจาก List ของ List โดยแต่ละ List ย่อยแทนข้อมูลในแถวหนึ่ง คล้ายกับการ transpose ข้อมูลแบบแถว-คอลัมน์ แต่ทำให้เป็นตารางจริงในทันที
Table.FromRows(rows as list, optional columns as any) as table
Table.FuzzyJoin ใช้สำหรับเชื่อม 2 ตารางเข้าด้วยกันโดยใช้คีย์ที่มีความคล้ายคลึงกัน (Fuzzy Matching) แทนที่จะต้องเหมือนกันทุกตัวอักษร สามารถกำหนดระดับความเหมือน (Threshold) และตัวเลือกอื่นๆ ได้
Table.FuzzyJoin(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinOptions as nullable record) as table
Table.Group จัดกลุ่มข้อมูลตามคอลัมน์ที่กำหนดและสรุปผลในแต่ละกลุ่มด้วย aggregation functions เช่น List.Sum, List.Count, List.Average คล้ายกับ GROUP BY ใน SQL แต่ทรงพลังกว่าเพราะสามารถจัดกลุ่มหลายคอลัมน์พร้อมกันและสร้างคอลัมน์สรุปผลหลายคอลัมน์ในคำสั่งเดียว รองรับ GroupKind.Local เพื่อเพิ่มประสิทธิภาพเมื่อข้อมูลเรียงลำดับแล้ว
Table.Group(table as table, key as any, aggregatedColumns as list, optional groupKind as nullable number, optional comparer as nullable function) as table
Table.IsEmpty ใช้สำหรับตรวจสอบว่าตารางไม่มีข้อมูล (ไม่มีแถว) ใช่หรือไม่ คืนค่า true หากตารางว่าง false หากมีข้อมูลอย่างน้อย 1 แถว
Table.IsEmpty(table as table) as logical
Table.Join ใช้รวมตารางสองตารางโดยจับคู่ค่าในคอลัมน์กำหนด สนับสนุนทุกประเภท join (Inner, Left Outer, Right Outer, Full Outer, Anti, Semi) เหมือน SQL Join
Table.Join(table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as nullable number, optional joinAlgorithm as nullable number, optional keyEqualityComparers as nullable list) as table
Table.Last ใช้ดึงแถวสุดท้ายของตารางออกมาเป็น Record หรือคืนค่าเริ่มต้นถ้าตารางว่างเปล่า
Table.Last(table as table, optional default as any) as any
Table.NestedJoin เชื่อมตารางสองตารางด้วยคีย์ที่กำหนด และสร้างคอลัมน์ใหม่ที่เก็บตารางย่อยของแถวที่จับคู่ได้ เหมาะกับงาน Merge ที่ต้องการเก็บรายละเอียดฝั่งขวาไว้เป็น nested table ก่อนจะ Expand หรือทำขั้นตอนต่อ
Table.NestedJoin(table1 as table, key1 as any, table2 as any, key2 as any, newColumnName as text, optional joinKind as nullable number, optional keyEqualityComparers as nullable list) as table
แบ่งตารางออกเป็นรายการของตารางย่อย (List of Tables) โดยใช้ hash function กำหนดการกระจายข้อมูล
Table.Partition(table as table, column as text, groups as number, hash as function) as list
Table.Pivot แปลงข้อมูล long format (แนวตั้ง) เป็น wide format (แนวนอน) โดยหมุนค่า attribute ให้เป็นคอลัมน์ใหม่
= Table.Pivot(table, pivotValues, attributeColumn, valueColumn, [aggregationFunction])
ค้นหาตำแหน่ง (Index) ของแถวในตาราง
Table.PositionOf(table as table, row as record, optional occurrence as nullable number, optional equationCriteria as any) as any
Table.PromoteHeaders เลื่อนข้อมูลในแถวแรกของตารางขึ้นมาเป็นชื่อคอลัมน์ และลบแถวนั้นออกจากส่วนข้อมูล รองรับพารามิเตอร์เสริม options เป็น record ที่มีฟิลด์ PromoteAllScalars สำหรับอนุญาตให้ค่าที่ไม่ใช่ข้อความ เช่น ตัวเลขและวันที่ ถูกแปลงเป็นชื่อคอลัมน์ได้ และ Culture สำหรับกำหนดรูปแบบการแปลงค่าตามภูมิภาค.ที่เจ๋งคือ PromoteAllScalars=true ช่วยให้หัวตารางที่เป็นตัวเลขหรือวันที่ก็ใช้ได้ ไม่ติดว่าต้องเป็นข้อความอย่างเดียว
Table.PromoteHeaders(table as table, optional options as nullable record) as table
Table.RemoveColumns ใช้ลบคอลัมน์เดียวหรือหลายคอลัมน์จาก table ครั้งเดียว เป็นวิธีที่สะดวกเมื่อต้องการลบ column ที่ไม่ต้องการ เช่น unwanted columns จากการโหลด Excel หรือ column ชั่วคราวหลังใช้คำนวณเสร็จ
Table.RemoveColumns(table as table, columns as any, optional missingField as nullable number) as table
Table.RemoveRows ใช้สำหรับลบแถวออกจากตาราง โดยระบุตำแหน่งเริ่มต้นและจำนวนแถวที่ต้องการลบ
Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table
Table.RenameColumns ใช้สำหรับเปลี่ยนชื่อคอลัมน์หนึ่งหรือหลายคอลัมน์ในตารางพร้อมกัน โดยส่งผ่าน list ของ rename pairs {ชื่อเก่า, ชื่อใหม่}
Table.RenameColumns(table as table, renames as list, optional missingField as nullable number) as table
จัดเรียงลำดับคอลัมน์ในตารางใหม่ตามลำดับที่ต้องการ พร้อมจัดการกรณีคอลัมน์หายไป
Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
Table.ReplacePartitionKey แทนที่ partition key ของตาราง ซึ่งเป็น metadata สำหรับการแบ่งพาร์ทิชันและการจัดการข้อมูลภายใน เอาไว้ควบคุมวิธีการแบ่งพาร์ทิชันของข้อมูลในตารางนั้น
Table.ReplacePartitionKey(table as table, partitionKey as nullable list) as table
Table.ReplaceValue ใช้สำหรับค้นหาและแทนที่ค่าในตารางได้หลายวิธี ตั้งแต่แทนที่ค่าทั้งหมดไปจนถึงแทนที่แบบมีเงื่อนไข
= Table.ReplaceValue(table as table, oldValue as any, newValue as any, replacer as function, columnsToSearch as list) as table
Table.ReverseRows คืนค่าตารางที่มีลำดับแถวตรงข้ามกับตารางต้นฉบับ (Reverse Order)
Table.ReverseRows(table as table) as table