Thep Excel

Table.Sort – เรียงลำดับข้อมูล

เรียงลำดับข้อมูลในตาราง

เรียงลำดับข้อมูลในตาราง

=Table.Sort(table as table, comparisonCriteria as any) as table

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=Table.Sort(table as table, comparisonCriteria as any) as table

Argument Type Required Default Description
table Table Yes ตารางข้อมูลที่ต้องการเรียงลำดับ
comparisonCriteria Any Yes เกณฑ์การเรียงลำดับ ระบุเป็นชื่อคอลัมน์ หรือ List ของคู่ {ชื่อคอลัมน์, ทิศทาง} เช่น Order.Ascending, Order.Descending

Examples

เรียงตามคอลัมน์เดียว

เรียงข้อมูลตามคอลัมน์ ID จากน้อยไปมาก
Power Query Formula:

let
    Source = #table({"ID", "Name"}, {{3, "C"}, {1, "A"}, {2, "B"}}),
    Sorted = Table.Sort(Source, { {"ID", Order.Ascending}} )
in
    Sorted

Result:

Table sorted by ID (1, 2, 3)

เรียงหลายคอลัมน์

เรียงตาม Region (ก-ฮ) ก่อน แล้วเรียงตาม Sales (มากไปน้อย) ในแต่ละ Region
Power Query Formula:

=Table.Sort(Source, { {"Region", Order.Ascending}, {"Sales", Order.Descending}})

Result:

Table

Resources & Related

Additional Notes

ฟังก์ชัน Table.Sort ใช้สำหรับเรียงลำดับข้อมูลในตารางตามคอลัมน์ที่กำหนด สามารถเรียงได้หลายระดับและกำหนดทิศทาง (จากน้อยไปมาก หรือ มากไปน้อย) ได้

Leave a Reply

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