---
title: List.IsEmpty – ตรวจสอบว่ารายการว่างเปล่า
url: https://www.thepexcel.com/functions/power-query/list-functions/list-isempty/
type: function-explainer
program: Power Query
syntax: List.IsEmpty(list as list) as logical
date: 2025-12-03
updated: 2025-12-26
scores:
  popularity: 5
  difficulty: 4
  usefulness: 5
---

# List.IsEmpty – ตรวจสอบว่ารายการว่างเปล่า

> List.IsEmpty ตรวจสอบว่ารายการไม่มีข้อมูลเลย คืนค่า true หากรายการว่าง false หากมีข้อมูล

## คำอธิบาย

List.IsEmpty ตรวจสอบว่ารายการไม่มีข้อมูลเลย คืนค่า true หากรายการว่าง false หากมีข้อมูล

## Syntax

```excel
List.IsEmpty(list as list) as logical
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | รายการที่ต้องการตรวจสอบว่าว่างเปล่าหรือมีข้อมูล |

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

### ตรวจสอบก่อนประมวลผล

ตรวจสอบว่า List ข้อมูลมีค่าหรือไม่ เพื่อหลีกเลี่ยง Error ก่อนที่จะนำไปใช้ในฟังก์ชันอื่นที่ต้องการข้อมูลอย่างน้อย 1 ตัว

### Filter ข้อมูล

ใช้กรอง Record หรือ Table ที่มีคอลัมน์ List ว่างเปล่าออกไป

## ตัวอย่าง

### 1. ตรวจสอบรายการว่าง

```excel
List.IsEmpty({})
```

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

รายการว่างเปล่า {} ไม่มีข้อมูลเลย ดังนั้น List.IsEmpty จึงคืนค่า true

### 2. ตรวจสอบรายการที่มีข้อมูล

```excel
List.IsEmpty({1, 2, 3})
```

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

รายการมีข้อมูล 3 รายการ ดังนั้น List.IsEmpty จึงคืนค่า false

### 3. ใช้กับตัวแปร

```excel
let
    myList = {"Apple", "Banana"},
    isEmpty = List.IsEmpty(myList)
in
    isEmpty
```

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

บันทึกรายการผลไม้ลงในตัวแปร myList จากนั้นตรวจสอบด้วย List.IsEmpty คืนค่า false เพราะมีข้อมูล

### 4. ใช้ในการตรวจสอบเงื่อนไข

```excel
if List.IsEmpty({}) then "ไม่มีข้อมูล" else "มีข้อมูล"
```

**ผลลัพธ์:** `"ไม่มีข้อมูล"`

ใช้ List.IsEmpty ในคำสั่ง if เพื่อตัดสินใจว่าจะแสดงข้อความใด

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

- ผมมักใช้ List.IsEmpty ก่อน List.First หรือ List.Last เพื่อหลีกเลี่ยง error จากรายการว่าง

- ส่วนตัวผม ใช้ List.IsEmpty ร่วมกับ if statement เพื่อสร้าง error handling ที่ดีในการแปลงข้อมูล

- ผมชอบเขียน let...in ที่ชัดเจน เพื่อให้รหัสอ่านง่าย และใช้ List.IsEmpty ตรวจสอบก่อนทำงานแต่ละขั้นตอน

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

**Q: ต่างกับ List.Count อย่างไร?**

List.Count นับจำนวนข้อมูลในรายการและคืนค่าตัวเลข ส่วน List.IsEmpty ตรวจสอบเฉพาะว่าว่างหรือไม่ เมื่อผมต้องเช็คว่ามีข้อมูลหรือเปล่า List.IsEmpty เร็วกว่าและอ่านง่ายกว่า

**Q: List.IsEmpty ใช้กับเรคอร์ด (record) ได้ไหม?**

ไม่ List.IsEmpty ใช้เฉพาะกับรายการ (list) เท่านั้น ถ้าต้องตรวจสอบเรคอร์ด ผมแนะนำใช้ Record.FieldCount หรือตรวจสอบฟิลด์เฉพาะ

**Q: null list กับ empty list ต่างกันไหม?**

ใช่ null list คือไม่มีค่าเลย ส่วน empty list {} คือรายการที่มี 0 รายการ ถ้าลองใช้ List.IsEmpty กับ null จะเกิด error ผมแนะนำให้ตรวจสอบ null ก่อนด้วย if [value]  null

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

- [List.Count – นับจำนวนรายการในลิสต์](https://www.thepexcel.com/functions/power-query/list-functions/list-count/)
- [List.NonNullCount – นับจำนวนค่าที่ไม่เป็น null](https://www.thepexcel.com/functions/power-query/list-functions/list-nonnullcount/)
- [Table.IsEmpty – ตรวจสอบว่าตารางว่างหรือไม่](https://www.thepexcel.com/functions/power-query/table-functions/table-isempty/)

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

- [Microsoft Learn - List.IsEmpty](https://learn.microsoft.com/en-us/powerquery-m/list-isempty) _(official)_
- [Microsoft Learn - List Functions](https://learn.microsoft.com/en-us/powerquery-m/list-functions) _(official)_

---

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