---
title: List.ContainsAny – ตรวจสอบว่า List มีสมาชิกบางตัวจากอีก List หรือไม่
url: https://www.thepexcel.com/functions/power-query/list-functions/list-containsany/
type: function-explainer
program: Power Query
syntax: "List.ContainsAny(list as list, values as list, optional equationCriteria as any) as logical"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# List.ContainsAny – ตรวจสอบว่า List มีสมาชิกบางตัวจากอีก List หรือไม่

> ตรวจสอบการมีอยู่ของสมาชิกอย่างน้อยหนึ่งตัวใน List

## คำอธิบาย

List.ContainsAny คืนค่า true ถ้า List หลักมีสมาชิกอย่างน้อยหนึ่งตัวจาก List ที่สอง

## Syntax

```excel
List.ContainsAny(list as list, values as list, optional equationCriteria as any) as logical
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ที่ต้องการค้นหา |
| values | Yes | list |  | List ของค่าที่ต้องการตรวจสอบว่ามีอยู่ใน List แรกหรือไม่ |
| equationCriteria | No | any | null | ตัวเลือกเสริมสำหรับกำหนดเกณฑ์การเปรียบเทียบ (เช่น Comparer.OrdinalIgnoreCase) |

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

### ตรวจสอบสิทธิ์การเข้าถึงแบบ OR

ใช้ตรวจสอบว่าผู้ใช้มีสิทธิ์ 'Admin' หรือ 'Editor' หรือไม่

### ตรวจจับคำสำคัญในข้อความ

ตรวจสอบว่า List ของคำมีคำต้องห้าม (blacklist) อยู่หรือไม่

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: พบสมาชิกอย่างน้อยหนึ่งตัว

```excel
List.ContainsAny({1, 2, 3, 4, 5}, {3, 9})
```

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

List `{1, 2, 3, 4, 5}` มีสมาชิก 3 ซึ่งอยู่ใน List ที่สอง ผลลัพธ์จึงเป็น true

### 2. ตัวอย่างที่ 2: ไม่พบสมาชิกตัวใดเลย

```excel
List.ContainsAny({1, 2, 3, 4, 5}, {6, 7})
```

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

List `{1, 2, 3, 4, 5}` ไม่มีทั้ง 6 และ 7 ผลลัพธ์จึงเป็น false

### 3. ตัวอย่างที่ 3: ตรวจสอบแบบไม่สนใจตัวพิมพ์เล็ก-ใหญ่

```excel
List.ContainsAny({"apple", "banana"}, {"APPLE"}, Comparer.OrdinalIgnoreCase)
```

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

ใช้ Comparer.OrdinalIgnoreCase เพื่อให้การเปรียบเทียบไม่สนใจ Case ผลลัพธ์จึงเป็น true

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

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

List.ContainsAny ตรวจสอบว่ามี 'อย่างน้อยหนึ่งตัว' ที่ตรงกัน ในขณะที่ List.ContainsAll ตรวจสอบว่ามี 'ทุกตัว' ที่ตรงกัน

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

- [List.Contains – ตรวจสอบว่า List มีสมาชิกที่กำหนดหรือไม่](https://www.thepexcel.com/functions/power-query/list-functions/list-contains/)
- [List.ContainsAll – ตรวจสอบว่า List มีสมาชิกทั้งหมดจากอีก List หรือไม่](https://www.thepexcel.com/functions/power-query/list-functions/list-containsall/)
- [List.AnyTrue – ตรวจสอบว่ามีสมาชิกบางตัวเป็น True](https://www.thepexcel.com/functions/power-query/list-functions/list-anytrue/)

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

- [Microsoft Learn: List.ContainsAny](https://learn.microsoft.com/en-us/powerquery-m/list-containsany) _(Official Documentation)_

---

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