Thep Excel

Record.SelectFields – เลือก Field ที่ต้องการจาก Record

Record.SelectFields จะคืนค่า Record ใหม่ที่มีเฉพาะ Field ที่ระบุใน List เท่านั้น สามารถจัดการกับ Field ที่หายไปได้ด้วย option missingField

=Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as record

By ThepExcel AI Agent
3 December 2025

Function Metrics


Popularity
5/10

Difficulty
3/10

Usefulness
5/10

Syntax & Arguments

=Record.SelectFields(record as record, fields as any, optional missingField as nullable number) as record

Argument Type Required Default Description
record record Yes Record ที่ต้องการเลือก Field
fields list/text Yes ชื่อ Field หรือ List ของชื่อ Field ที่ต้องการเก็บไว้
missingField number Optional MissingField.Error กำหนดพฤติกรรมเมื่อไม่พบ Field (เช่น MissingField.UseNull)

How it works

ลดขนาด Record

เลือกเฉพาะข้อมูลสำคัญ เช่น ID และ Name จาก Record ที่มีข้อมูลเยอะๆ

จัดลำดับ Field ใหม่

Record ใหม่ที่ได้จะมีลำดับ Field ตามที่ระบุใน List

Examples

Select specific fields from a product record
Record.SelectFields([OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0], {"Item", "Price"})
Returns only Item and Price fields, omitting OrderID and CustomerID
Power Query Formula:

=Record.SelectFields([OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0], {"Item", "Price"})

Result:

[Item = "Fishing rod", Price = 100.0]

Extract contact information with reordering
Record.SelectFields([FirstName = "John", LastName = "Smith", Email = "john@example.com", Phone = "555-1234", Address = "123 Main St"], {"Email", "Phone", "First…
Selects contact fields and reorders them with Email first
Power Query Formula:

=Record.SelectFields([FirstName = "John", LastName = "Smith", Email = "john@example.com", Phone = "555-1234", Address = "123 Main St"], {"Email", "Phone", "FirstName"})

Result:

[Email = "john@example.com", Phone = "555-1234", FirstName = "John"]

Filter catalog data for API response
Record.SelectFields([SKU = "ABC123", Name = "Widget", Cost = 25, Retail = 49.99, Supplier = "AcmeCorp"], {"SKU", "Name", "Retail"})
Extract public-facing fields for API response, excluding cost and supplier information
Power Query Formula:

=Record.SelectFields([SKU = "ABC123", Name = "Widget", Cost = 25, Retail = 49.99, Supplier = "AcmeCorp"], {"SKU", "Name", "Retail"})

Result:

[SKU = "ABC123", Name = "Widget", Retail = 49.99]

FAQs

ต่างจาก Record.RemoveFields อย่างไร?

Record.SelectFields เลือกสิ่งที่ “เก็บ” ส่วน Record.RemoveFields เลือกสิ่งที่ “ทิ้ง”

Resources & Related

Additional Notes

ฟังก์ชัน Record.SelectFields ใน Power Query ใช้สำหรับเลือกเก็บเฉพาะ Field ที่ต้องการจาก Record และตัด Field อื่นทิ้งไป ช่วยให้ Record เล็กลงและเหลือเฉพาะข้อมูลที่จำเป็น

Leave a Reply

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