---
title: List.AnyTrue – ตรวจสอบว่ามีสมาชิกบางตัวเป็น True
url: https://www.thepexcel.com/functions/power-query/list-functions/list-anytrue/
type: function-explainer
program: Power Query
syntax: List.AnyTrue(list as list) as logical
date: 2025-12-03
updated: 2025-12-26
scores:
  popularity: 5
  difficulty: 4
  usefulness: 5
---

# List.AnyTrue – ตรวจสอบว่ามีสมาชิกบางตัวเป็น True

> List.AnyTrue คืนค่า true หากมีเงื่อนไขอย่างน้อยหนึ่งข้อใน List เป็นจริง

## คำอธิบาย

List.AnyTrue คืนค่า true หากมีเงื่อนไขอย่างน้อยหนึ่งข้อใน List เป็นจริง

## Syntax

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

## Arguments

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

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

### ตรวจสอบความผิดปกติ

ใช้ตรวจสอบว่ามี Error หรือค่าผิดปกติเกิดขึ้นในรายการใดรายการหนึ่งหรือไม่ (เช่น มีสินค้าใดสินค้าหนึ่งหมดสต็อกหรือไม่)

### เงื่อนไขแบบ OR หลายข้อ

แทนการเขียน if condition1 or condition2 or condition3... สามารถรวมเงื่อนไขเป็น List แล้วใช้ List.AnyTrue แทนได้

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: มีเงื่อนไขบางข้อเป็นจริง

```excel
List.AnyTrue({true, false, 2 > 0})
```

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

ใน List มีทั้ง true, false และ 2 > 0 (ซึ่งคือ true) เนื่องจากมีค่าความจริงอยู่อย่างน้อย 1 ตัว ผลลัพธ์จึงเป็น true

### 2. ตัวอย่างที่ 2: เงื่อนไขทั้งหมดเป็นเท็จ

```excel
List.AnyTrue({2 = 0, false, 2 < 0})
```

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

2 = 0 เป็น false, false เป็น false, และ 2 < 0 เป็น false เนื่องจากไม่มีสมาชิกตัวใดเลยที่เป็นจริง ผลลัพธ์จึงเป็น false

### 3. ตัวอย่างที่ 3: List ว่างเปล่า

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

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

List ว่างเปล่าถือว่า 'ไม่มีสมาชิกตัวใดที่เป็นจริง' ดังนั้นจึงคืนค่าเป็น false (ต่างจาก List.AllTrue ที่คืนค่า true)

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

- ผมชอบใช้ List.AnyTrue ในการตรวจสอบว่า 'มีข้อมูลเสียหาย' ได้ไหม เช่น {IsEmpty1, IsEmpty2, IsEmpty3} จากคอลัมน์ต่าง ๆ

- ส่วนตัวผม ผมจะระวังการ nesting List.AnyTrue ข้างใน List.Select เพราะมันอาจทำให้ query ช้ากว่าที่ควร เลยใช้ List.AnyTrue ที่ wrapper level ดีกว่า

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

**Q: List.AnyTrue ต่างจาก List.AllTrue อย่างไร?**

ผมอธิบายให้ชัด ๆ นะ List.AnyTrue ใช้เงื่อนไข OR (ขอแค่ 1 ตัวจริงก็พอ) ส่วน List.AllTrue ใช้เงื่อนไข AND (ต้องจริงทุกตัว) ตัวอย่าง: List.AnyTrue({false, false, true}) = true แต่ List.AllTrue({false, false, true}) = false

**Q: ผมจะรู้ได้ไงว่า List ว่างเปล่าให้ผลเป็น true หรือ false?**

ผมได้ลองแล้ว List.AnyTrue({}) คืนค่า false เพราะ 'ไม่มีสมาชิกจริง' ส่วน List.AllTrue({}) คืนค่า true นี่เรียกว่า vacuous truth ทางคณิตศาสตร์

**Q: ใช้ได้กับข้อมูลชนิดไหนบ้าง?**

ผมแนะนำให้ใช้กับค่าตรรกะและการเปรียบเทียบค่า เช่น {2>0, 3

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

- [List.AllTrue – ตรวจสอบว่าสมาชิกทุกตัวเป็น True](https://www.thepexcel.com/functions/power-query/list-functions/list-alltrue/)
- [List.Contains – ตรวจสอบว่า List มีสมาชิกที่กำหนดหรือไม่](https://www.thepexcel.com/functions/power-query/list-functions/list-contains/)
- [List.ContainsAny – ตรวจสอบว่า List มีสมาชิกบางตัวจากอีก List หรือไม่](https://www.thepexcel.com/functions/power-query/list-functions/list-containsany/)
- [List.MatchesAny – ตรวจสอบว่ามีสมาชิกบางตัวตรงตามเงื่อนไขหรือไม่](https://www.thepexcel.com/functions/power-query/list-functions/list-matchesany/)

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

- [Microsoft Learn: List.AnyTrue](https://learn.microsoft.com/en-us/powerquery-m/list-anytrue) _(official)_

---

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