Thep Excel

List.AllTrue – ตรวจสอบว่าสมาชิกทุกตัวเป็น True

List.AllTrue คืนค่า true หากทุกเงื่อนไขใน List เป็นจริงทั้งหมด

=List.AllTrue(list as list) as logical

By ThepExcel AI Agent
3 December 2025

Function Metrics


Popularity
4/10

Difficulty
3/10

Usefulness
4/10

Syntax & Arguments

=List.AllTrue(list as list) as logical

Argument Type Required Default Description
list list Yes List ของค่าตรรกะ (logical values) หรือการแสดงออกที่คืนค่าเป็น true/false

How it works

ตรวจสอบสถานะทั้งหมด

ใช้ตรวจสอบว่าทุกสถานะใน List เป็น 'Completed' หรือ 'Valid' ทั้งหมดหรือไม่

ยืนยันเงื่อนไขหลายข้อพร้อมกัน

ตรวจสอบว่าเงื่อนไขหลายข้อที่ซับซ้อน (เช่น การตรวจสอบข้อมูลจากหลายคอลัมน์) เป็นจริงทั้งหมดหรือไม่

Examples

ตัวอย่างที่ 1: ทุกเงื่อนไขเป็นจริง
List.AllTrue({true, true, 2 > 0})
ใน List `{true, true, 2 > 0}` ทุกองค์ประกอบเป็นจริง (2 > 0 คือ true) ดังนั้นฟังก์ชันจึงคืนค่าเป็น true
Power Query Formula:

=List.AllTrue({true, true, 2 > 0})

Result:

true

ตัวอย่างที่ 2: มีเงื่อนไขที่เป็น False
List.AllTrue({true, false, 2 < 0})
ใน List `{true, false, 2 < 0}` มีองค์ประกอบที่เป็น false อย่างน้อยหนึ่งตัว (false และ 2 < 0 คือ false) ดังนั้นฟังก์ชันจึงคืนค่าเป็น false
Power Query Formula:

=List.AllTrue({true, false, 2 < 0})

Result:

false

ตัวอย่างที่ 3: List ว่างเปล่า
List.AllTrue({})
List ว่างเปล่าจะถูกพิจารณาว่าไม่มีองค์ประกอบใดเป็น false ดังนั้นจึงคืนค่าเป็น true เสมอ
Power Query Formula:

=List.AllTrue({})

Result:

true

FAQs

List.AllTrue แตกต่างจาก List.MatchesAll อย่างไร?

List.AllTrue ใช้ตรวจสอบเฉพาะค่าตรรกะ (true/false) เท่านั้น ในขณะที่ List.MatchesAll ใช้ตรวจสอบเงื่อนไขที่ซับซ้อนกว่าโดยใช้ฟังก์ชัน predicate (เช่น ตรวจสอบว่าตัวเลขทุกตัวมากกว่า 0 หรือไม่)

Resources & Related

Additional Notes

ฟังก์ชัน List.AllTrue ใน Power Query จะคืนค่าเป็น true หากเงื่อนไขหรือการแสดงออกทางตรรกะทั้งหมดใน List ที่กำหนดมีค่าเป็นจริง ถ้ามีเงื่อนไขใดใน List เป็น false หรือ null ฟังก์ชันจะคืนค่าเป็น false

Leave a Reply

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