Thep Excel

Table.Pivot – กระจายข้อมูลแถวเป็นคอลัมน์ (Pivot)

กระจายข้อมูลแถวเป็นคอลัมน์ (Pivot)

กระจายข้อมูลแถวเป็นคอลัมน์ (Pivot)

=Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as table

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=Table.Pivot(table as table, pivotValues as list, attributeColumn as text, valueColumn as text, optional aggregationFunction as nullable function) as table

Argument Type Required Default Description
table Table Yes ตารางข้อมูล
pivotValues List Yes รายการค่าที่ไม่ซ้ำกันของคอลัมน์ที่จะนำมาเป็นหัวคอลัมน์ใหม่
attributeColumn Text Yes ชื่อคอลัมน์ที่มีค่าที่จะกลายเป็นหัวคอลัมน์
valueColumn Text Yes ชื่อคอลัมน์ที่มีค่าข้อมูล
aggregationFunction Function Optional ฟังก์ชันสรุปผล เช่น List.Sum, List.Count

Examples

Pivot ข้อมูลยอดขาย

เปลี่ยน Region (North, South) ให้เป็นคอลัมน์ และใส่ค่า Sales ลงไป
Power Query Formula:

let
    Source = #table(
        {"Year", "Region", "Sales"},
        {{2023, "North", 100}, {2023, "South", 200}}     ),
    Pivoted = Table.Pivot(
        Source,
        List.Distinct(Source[Region]),
        "Region", "Sales", List.Sum
    )
in
    Pivoted

Result:

Table (Year, North, South)

Resources & Related

Additional Notes

ฟังก์ชัน Table.Pivot ใช้สำหรับเปลี่ยนข้อมูลในแถวให้กลายเป็นคอลัมน์ (Pivot) โดยสามารถระบุฟังก์ชันการสรุปผล (Aggregation) ได้

Leave a Reply

Your email address will not be published. Required fields are marked *