---
title: Table.ExpandListColumn – ขยาย List เป็นหลายแถว
url: https://www.thepexcel.com/functions/power-query/table-functions/table-expandlistcolumn/
type: function-explainer
program: Power Query
syntax: "Table.ExpandListColumn(table as table, column as text) as table"
date: 2025-12-06
updated: 2025-12-22
scores:
  popularity: 7
  difficulty: 4
  usefulness: 7
---

# Table.ExpandListColumn – ขยาย List เป็นหลายแถว

> Table.ExpandListColumn ใช้สำหรับขยายคอลัมน์ที่เก็บข้อมูลแบบ List ให้เป็นแถวแยก โดยแต่ละรายการใน List

## คำอธิบาย

Table.ExpandListColumn ใช้สำหรับขยายคอลัมน์ที่เก็บข้อมูลแบบ List ให้เป็นแถวแยก โดยแต่ละรายการใน List จะกลายเป็นแถวใหม่ ส่วนข้อมูลในคอลัมน์อื่นจะถูกทำซ้ำตามจำนวน

## Syntax

```excel
Table.ExpandListColumn(table as table, column as text) as table
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| table | Yes | table |  | ตารางที่ต้องการขยายคอลัมน์ที่เป็น List |
| column | Yes | text |  | ชื่อคอลัมน์ (ในรูป Text) ที่เก็บข้อมูลแบบ List ที่ต้องการขยาย |

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

### จัดการข้อมูล JSON Array ที่ Import เข้ามา

จัดการข้อมูล JSON Array ที่ Import เข้ามา

### แตกข้อมูล Tags หรือ Categories ที่อยู่ในช่องเดียวกัน

แตกข้อมูล Tags หรือ Categories ที่อยู่ในช่องเดียวกัน

### เตรียมข้อมูลสำหรับการวิเคราะห์รายรายการย่อย

เตรียมข้อมูลสำหรับการวิเคราะห์รายรายการย่อย

## ตัวอย่าง

### 1. ขยาย List พื้นฐาน

```excel
let
    Source = #table(
        {"ProductID", "Tags"},
        {{1, {"Electronics", "Gadgets"}}, {2, {"Home"}}, {3, {"Kitchen", "Appliances", "Useful"}}}
    ),
    Expanded = Table.ExpandListColumn(Source, "Tags")
in
    Expanded
```

**ผลลัพธ์:** `ProductID | Tags
1         | Electronics
1         | Gadgets
2         | Home
3         | Kitchen
3         | Appliances
3         | Useful`

แต่ละ Tag จาก List จะกลายเป็นแถวใหม่ โดย ProductID จะถูกทำซ้ำให้ตรงกับจำนวน Tag ในแต่ละแถว

### 2. จัดการกับ null และ Empty List

```excel
let
    Source = #table(
        {"Name", "Hobbies"},
        {{"Alice", {"Reading", "Gaming"}}, {"Bob", null}, {"Charlie", {}}}
    ),
    Expanded = Table.ExpandListColumn(Source, "Hobbies")
in
    Expanded
```

**ผลลัพธ์:** `Name    | Hobbies
Alice   | Reading
Alice   | Gaming
Bob     | null
Charlie | null`

ค่า null จะยังคงอยู่ (ไม่หายไป) ส่วน List ว่าง {} จะกลายเป็น null หนึ่งแถว หลีกเลี่ยงการสูญเสียแถวข้อมูล

### 3. ขยาย List of Records พร้อม ExpandRecordColumn

```excel
let
    Source = #table(
        {"OrderID", "Items"},
        {{
            1,
            {[ProductName = "Laptop", Qty = 1], [ProductName = "Mouse", Qty = 2]}
        }}
    ),
    ExpandList = Table.ExpandListColumn(Source, "Items"),
    ExpandRecord = Table.ExpandRecordColumn(ExpandList, "Items", {"ProductName", "Qty"})
in
    ExpandRecord
```

**ผลลัพธ์:** `OrderID | ProductName | Qty
1       | Laptop      | 1
1       | Mouse       | 2`

ก่อนอื่นขยาย List ให้เป็นแถว จากนั้นขยาย Record ซ้อนอยู่ด้านใน สำหรับจัดการข้อมูลแบบ Nested ที่มีหลายชั้น

### 4. ขยายหลายคอลัมน์แบบ Sequential

```excel
let
    Source = #table(
        {"ID", "Colors", "Sizes"},
        {{
            1,
            {"Red", "Blue"},
            {"S", "M", "L"}
        }}
    ),
    ExpandColors = Table.ExpandListColumn(Source, "Colors"),
    ExpandSizes = Table.ExpandListColumn(ExpandColors, "Sizes")
in
    ExpandSizes
```

**ผลลัพธ์:** `ID | Colors | Sizes
1  | Red    | S
1  | Red    | M
1  | Red    | L
1  | Blue   | S
1  | Blue   | M
1  | Blue   | L`

ขยายคอลัมน์ Colors ก่อน จากนั้นขยาย Sizes ทำให้ได้ Cartesian Product ของ Color × Size Combination

## หมายเหตุเพิ่มเติม

- ถ้า List ว่าง ({}) จะกลายเป็น null row ให้ใช้ Table.SelectRows กรองออกหากไม่ต้องการ

- ใช้ Table.Column(table, "ColumnName") เพื่อดึงคอลัมน์ที่มี List เพื่อดูโครงสร้าง

- เวลาขยายหลายคอลัมน์ ลำดับเรื่องสำคัญ - ขยาย List ก่อน List ที่มี Record ด้วย

- ส่วนตัวผมชอบให้ชื่อคอลัมน์ชัดเจน เช่น "Tags", "Items", "Details" เพื่อให้ง่ายต่อการ Debug ในภายหลัง

## คำถามที่พบบ่อย

**Q: ทำไมถึงมี null แถวเพิ่มเติมตอนมี empty list?**

นี่เป็นการป้องกันการสูญเสียแถว ถ้า List ว่าง ฟังก์ชันจะสร้าง null แถวหนึ่ง เพื่อไม่ให้หายไปทั้งแถว ส่วนตัวผมชอบจุดนี้เพราะไม่ต้องกังวลว่าจะหาที่ไปของข้อมูล 😎

**Q: ถ้าต้องการขยายหลายคอลัมน์พร้อมกันทำไง?**

ต้องทำแบบ Sequential (ทีละคอลัมน์) ไม่มีวิธีขยายหลายคอลัมน์พร้อมกันในครั้งเดียว ส่วนตัวผมแนะนำให้สร้าง Step แยกสำหรับแต่ละการขยาย ทำให้อ่านและ Debug ง่ายขึ้น

**Q: ใช้กับ Table.ExpandRecordColumn ยังไง?**

ใช้ Table.ExpandListColumn ก่อน (เพื่อขยาย List) แล้วตามด้วย Table.ExpandRecordColumn (เพื่อแตกผ้าของ Record) นี่คือเทคนิคทั่วไปสำหรับจัดการ Nested Data

**Q: ถ้า List มีค่าเดียวจะแตกออกไหม?**

ไม่แตก เพราะมีค่าเดียวอยู่แล้ว หากต้องการเพิ่มแถว ต้องให้ List มี 2 รายการขึ้นไป

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

- [Table.ExpandRecordColumn – ขยายคอลัมน์ที่เป็น Record ให้เป็นหลายคอลัมน์](https://www.thepexcel.com/?post_type=function-explainer&p=37949)
- [Table.ExpandTableColumn – แตกข้อมูลจากคอลัมน์ตารางที่ซ้อนกัน](https://www.thepexcel.com/functions/power-query/table-functions/table-expandtablecolumn/)
- [Table.SelectRows – กรองแถวตามเงื่อนไขใน Power Query](https://www.thepexcel.com/functions/power-query/table-functions/table-selectrows/)
- [Table.AddColumn – เพิ่มคอลัมน์ใหม่ด้วย Calculated Values](https://www.thepexcel.com/functions/power-query/table-functions/table-addcolumn/)

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

- [Microsoft Learn: Table.ExpandListColumn](https://learn.microsoft.com/en-us/powerquery-m/table-expandlistcolumn) _(official)_
- [PowerQuery.how - ExpandListColumn](https://powerquery.how/table-expandlistcolumn/) _(article)_
- [Microsoft Learn: Table.ExpandRecordColumn](https://learn.microsoft.com/en-us/powerquery-m/table-expandrecordcolumn) _(official)_

---

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