Thep Excel

Table.First – ดึงข้อมูลแถวแรก

ดึงข้อมูลแถวแรก (Record)

ดึงข้อมูลแถวแรก (Record)

=Table.First(table as table, optional default as any) as any

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=Table.First(table as table, optional default as any) as any

Argument Type Required Default Description
table Table Yes ตารางข้อมูล
default Any Optional null ค่าที่จะคืนกลับถ้าตารางว่างเปล่า (ถ้าไม่ระบุและตารางว่าง จะคืนค่า error)

Examples

ดึงแถวแรก

คืนค่า Record ของแถวแรกสุด
Power Query Formula:

let
    Source = Table.FromRecords({
        [CustomerID = 1, Name = "Bob", Sales = 100],
        [CustomerID = 2, Name = "Jim", Sales = 200],
        [ID = 3, Name = "Paul", Sales = 300]
    }),
    Result = Table.First(Source)
in
    Result

Result:

Record: [CustomerID=1, Name="Bob"...]

กรณีตารางว่าง

ถ้าตารางว่าง จะคืนค่า Default ที่ระบุไว้แทน (แทนที่จะเกิด error)
Power Query Formula:

let
    EmptyTable = Table.FromRecords({}),
    Result = Table.First(EmptyTable, [CustomerID = 0, Name = "Default"])
in
    Result

Result:

Record: [CustomerID=0, Name="Default"]

ตัวอย่างที่ 3: ดึงค่าจาก Field ใน Record แถวแรก

ดึงแถวแรกมาเป็น Record แล้วดึงค่าจาก Field Product ออกมา ได้ "Apple"
Power Query Formula:

let
    Source = Table.FromRecords({
        [Product = "Apple", Price = 50],
        [Product = "Banana", Price = 30]
    }),
    FirstRow = Table.First(Source),
    FirstProduct = FirstRow[Product]
in
    FirstProduct

Result:

"Apple"

Resources & Related

Additional Notes

ฟังก์ชัน Table.First ใช้ดึงข้อมูลแถวแรกของตารางออกมาเป็น Record

Leave a Reply

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