Thep Excel

List.Count – นับจำนวนรายการใน List

นับจำนวนสมาชิกทั้งหมดใน List

List.Count จะคืนค่าจำนวนสมาชิกทั้งหมดใน List โดยนับทุกรายการไม่ว่าจะเป็นค่าอะไร (รวม null ด้วย) หากต้องการนับเฉพาะที่ไม่ว่างต้องใช้ List.NonNullCount

=List.Count(list as list) as number

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=List.Count(list as list) as number

Argument Type Required Default Description
list list Yes List ที่ต้องการนับจำนวน

How it works

นับจำนวนแถว

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

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

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

นับจำนวนคำ

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

Examples

ตัวอย่างที่ 1: นับจำนวนตัวเลข

มีสมาชิก 5 ตัวใน List
Power Query Formula:

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

Result:

5

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

List.Count นับค่า null ด้วย ถือเป็นสมาชิก 1 ตัว
Power Query Formula:

=List.Count({1, null, 3})

Result:

3

ตัวอย่างที่ 3: นับจำนวนสินค้า

นับจำนวนรายการทั้งหมดในคอลัมน์ ProductID
Power Query Formula:

=List.Count(Source[ProductID])

Result:

จำนวนสินค้าทั้งหมด

FAQs

ถ้าอยากนับเฉพาะที่ไม่ซ้ำทำอย่างไร?

ต้องใช้ List.Distinct ก่อนครับ เช่น List.Count(List.Distinct(MyList))

List.Count ต่างจาก Table.RowCount อย่างไร?

ให้ผลลัพธ์เหมือนกันถ้านับทั้งตาราง แต่ List.Count ใช้กับ List (คอลัมน์เดียว) ส่วน Table.RowCount ใช้กับ Table (ทั้งตาราง)

Resources & Related

Additional Notes

ฟังก์ชัน List.Count ใน Power Query ใช้สำหรับนับจำนวนรายการทั้งหมดที่มีอยู่ใน List (รวมถึงค่าว่างและค่าซ้ำ) มักใช้ในการนับจำนวนแถว, จำนวนรายการสินค้า หรือใช้ตรวจสอบว่า List มีข้อมูลหรือไม่

Leave a Reply

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