---
title: List.Count – นับจำนวนรายการในลิสต์
url: https://www.thepexcel.com/functions/power-query/list-functions/list-count/
type: function-explainer
program: Power Query
syntax: List.Count(list)
date: 2025-12-03
updated: 2025-12-23
scores:
  popularity: 8
  difficulty: 2
  usefulness: 8
---

# List.Count – นับจำนวนรายการในลิสต์

> List.Count ใช้นับจำนวนสมาชิกทั้งหมดในลิสต์ (รวม null) ส่งคืนค่าตัวเลข ถ้าต้องการนับเฉพาะที่ไม่ว่างให

## คำอธิบาย

List.Count ใช้นับจำนวนสมาชิกทั้งหมดในลิสต์ (รวม null) ส่งคืนค่าตัวเลข ถ้าต้องการนับเฉพาะที่ไม่ว่างให้ใช้ List.NonNullCount แทน

## Syntax

```excel
List.Count(list)
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | List |  | ลิสต์ที่ต้องการนับจำนวนสมาชิก (ลิสต์ของตัวเลข, ข้อความ, ระเบียน หรือโครงสร้างอื่นๆ) |

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

### นับจำนวนแถว

ใช้นับว่าตารางนี้มีกี่แถว (โดยแปลง Table เป็น List หรือนับ Key Column)

### ตรวจสอบเงื่อนไข

ใช้เช็คว่า List.Count > 0 หรือไม่ เพื่อดูว่ามีข้อมูลหรือไม่ก่อนทำขั้นตอนถัดไป

### นับจำนวนคำ

ใช้ Text.Split เพื่อแยกประโยคเป็น List แล้วใช้ List.Count เพื่อนับจำนวนคำ

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: นับตัวเลขในลิสต์

```excel
= List.Count({1, 2, 3, 4, 5})
```

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

ลิสต์ {1, 2, 3, 4, 5} มี 5 สมาชิก ส่งคืน 5

### 2. ตัวอย่างที่ 2: นับรวมค่า null

```excel
= List.Count({"Apple", null, "Banana", ""})
```

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

List.Count นับค่า null และสตริงว่างเป็นสมาชิก เพราะฉะนั้นนับได้ 4 ตัว (null กับสตริงว่างต่างกัน)

### 3. ตัวอย่างที่ 3: นับจากการกรองข้อมูล

```excel
let
    Sales = Table.FromRows({{"Alice", 150}, {"Bob", 75}, {"Carol", 120}}, {"Name", "Amount"}),
    HighSales = List.Select(Sales[Amount], each _ > 100),
    Count = List.Count(HighSales)
in
    Count
```

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

กรองเฉพาะข้อมูล Amount > 100 (150 และ 120) ส่งคืน 2

### 4. ตัวอย่างที่ 4: นับค่าซ้ำ

```excel
= List.Count({"Red", "Blue", "Red", "Green", "Red"})
```

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

List.Count นับค่าซ้ำ ไม่มีการกำจัด ทั้งหมด 5 ตัว ถ้าต้องการนับเฉพาะที่ไม่ซ้ำให้ใช้ List.Count(List.Distinct(...))

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

- ใช้ List.Count เพื่อตรวจสอบว่ามีข้อมูลหรือไม่ เช่น if List.Count(MyList) > 0 then ... else ...

- ถ้านับจากคอลัมน์ตารางแล้ว List.Count ก็เหมือน Table.RowCount ทั้งคู่ ใช้ตัวไหนก็ได้แต่ชัดเจน

- List.Count นับ null เป็นสมาชิก ถ้าต้องการนับเฉพาะค่าจริง ให้ใช้ List.NonNullCount แทน

- ถ้ากรองข้อมูลแล้ว List.Count จะบอกว่าเหลือกี่ตัว ใช้เพื่อควบคุมคุณภาพข้อมูล

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

**Q: ถ้าต้องการนับเฉพาะค่าที่ไม่ซ้ำให้ทำยังไง?**

ใช้ List.Distinct ก่อน แล้วค่อย List.Count ครับ เช่น = List.Count(List.Distinct({1, 2, 2, 3})) ส่งคืน 3 แทนที่จะ 4

**Q: List.Count กับ Table.RowCount ต่างกันยังไง?**

List.Count ใช้กับลิสต์ (เช่น {1, 2, 3} หรือ Source[ColumnName]) ส่วน Table.RowCount ใช้กับตาราง ถ้านับทั้งตารางผลลัพธ์จะเหมือนกัน

**Q: ถ้าลิสต์ว่างเปล่า List.Count จะส่งคืนอะไร?**

ส่งคืน 0 ถ้าลิสต์ว่าง {} List.Count({}) = 0

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

List.Count นับทั้งหมด รวม null ส่วน List.NonNullCount ไม่นับ null หากข้อมูลมี null อยู่ผลลัพธ์จะต่างกัน

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

- [Microsoft Learn: List.Count](https://learn.microsoft.com/en-us/powerquery-m/list-count) _(official)_
- [PowerQuery.how List Functions](https://powerquery.how/list-functions/) _(article)_

---

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