---
title: Record.FromList – สร้าง Record จาก List ของค่าและชื่อ Field
url: https://www.thepexcel.com/functions/power-query/record-functions/record-fromlist/
type: function-explainer
program: Power Query
syntax: "Record.FromList(list as list, fields as any) as record"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 4
  difficulty: 4
  usefulness: 4
---

# Record.FromList – สร้าง Record จาก List ของค่าและชื่อ Field

> สร้าง Record จาก List

## คำอธิบาย

สร้าง Record จาก List ของค่า และ List ของชื่อ Field

## Syntax

```excel
Record.FromList(list as list, fields as any) as record
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ของค่าข้อมูล (Values) ที่ต้องการใส่ใน Record |
| fields | Yes | any |  | List ของชื่อ Field (Text) หรือ Type ของ Record ที่ต้องการสร้าง |

## เคสการใช้งาน

### Zip ข้อมูล 2 List เข้าด้วยกัน

เมื่อมี List ของ Header และ List ของ Data แยกกัน สามารถใช้ฟังก์ชันนี้รวมเป็น Record ได้

### สร้าง Record แบบ Dynamic

เมื่อชื่อ Field และค่าข้อมูลมีการเปลี่ยนแปลงหรือไม่แน่นอน

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: สร้าง Record จาก List ของชื่อและค่า

```excel
Record.FromList({1, "Bob"}, {"ID", "Name"})
```

**ผลลัพธ์:** `[ID=1, Name="Bob"]`

จับคู่ค่าตัวแรกกับชื่อแรก และค่าตัวที่สองกับชื่อที่สอง

### 2. ตัวอย่างที่ 2: ใช้ Type ในการกำหนด Field

```excel
Record.FromList({1, "Bob"}, type [ID = number, Name = text])
```

**ผลลัพธ์:** `[ID=1, Name="Bob"]`

สามารถระบุเป็น Record Type แทน List ของชื่อได้

### 3. ตัวอย่างที่ 3: ข้อมูลและชื่อจำนวนไม่เท่ากัน (Error)

```excel
Record.FromList({1}, {"A", "B"})
```

**ผลลัพธ์:** `Error`

หากจำนวนสมาชิกใน List ของค่า และ List ของชื่อไม่เท่ากัน จะเกิด Error

## ฟังก์ชันที่เกี่ยวข้อง

- [Record.ToList – แปลง Record เป็น List ของค่าข้อมูล](https://www.thepexcel.com/functions/power-query/record-functions/record-tolist/)
- [Table.FromList – สร้างตารางจาก List](https://www.thepexcel.com/functions/power-query/table-functions/table-fromlist/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Record.FromList](https://learn.microsoft.com/en-us/powerquery-m/record-fromlist) _(Official Documentation)_
- [PowerQuery.how](https://powerquery.how/record-fromlist/) _(guide)_

---

_Source: [https://www.thepexcel.com/functions/power-query/record-functions/record-fromlist/](https://www.thepexcel.com/functions/power-query/record-functions/record-fromlist/)_
