---
title: List.FindText – ค้นหาข้อความภายใน List
url: https://www.thepexcel.com/functions/power-query/list-functions/list-findtext/
type: function-explainer
program: Power Query
syntax: "List.FindText(list as list, text as text) as list"
date: 2025-12-03
updated: 2025-12-26
scores:
  popularity: 5
  difficulty: 4
  usefulness: 5
---

# List.FindText – ค้นหาข้อความภายใน List

> List.FindText ค้นหาสมาชิกในรายการที่มีข้อความย่อยที่กำหนด เหมาะเมื่อต้องการกรองข้อมูลไม่ใช่แค่ตรงแม่

## คำอธิบาย

List.FindText ค้นหาสมาชิกในรายการที่มีข้อความย่อยที่กำหนด เหมาะเมื่อต้องการกรองข้อมูลไม่ใช่แค่ตรงแม่นทั้งคำ แต่ต้องการค้นหาแบบบางส่วนก็ได้

## Syntax

```excel
List.FindText(list as list, text as text) as list
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ที่ต้องการค้นหา (ต้องเป็นรายการข้อความ) |
| text | Yes | text |  | ข้อความย่อย (Substring) ที่ต้องการค้นหา |

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

### ค้นหาสินค้าที่เกี่ยวข้อง

ค้นหารายการสินค้าที่มีคำว่า "Samsung" หรือ "iPhone" อยู่ในชื่อสินค้า

### กรองข้อความใน Log File

เลือกเฉพาะบรรทัดใน Log File ที่มีคำว่า "Error" หรือ "Warning" เพื่อตรวจสอบปัญหา

## ตัวอย่าง

### 1. ค้นหาตัวอักษรเดียว

```excel
List.FindText({"apple", "banana", "cherry"}, "a")
```

**ผลลัพธ์:** `{"apple", "banana"}`

ค้นหาสมาชิกที่มีตัวอักษร 'a' อยู่ - apple มี a ที่เหมือน banana มี a แต่ cherry ไม่มี

### 2. ค้นหาคำภายในข้อความ

```excel
List.FindText({"Power Query", "Query Language", "SQL"}, "Query")
```

**ผลลัพธ์:** `{"Power Query", "Query Language"}`

ค้นหาคำว่า 'Query' - ได้ทั้ง 'Power Query' และ 'Query Language' เพราะทั้งคู่มีคำนี้อยู่

### 3. ค้นหาจากหลายสมาชิก

```excel
List.FindText({"Product-001", "Product-002", "Order-001", "Order-002"}, "Product")
```

**ผลลัพธ์:** `{"Product-001", "Product-002"}`

ค้นหาสมาชิกที่มี 'Product' - ได้เฉพาะรหัสสินค้า ไม่ได้รหัสออเดอร์

### 4. ค้นหาเชื่อมกับ Table.SelectRows

```excel
let
  Data = Table.FromRecords({{Name="Alice Smith", Age=25}, {Name="Bob Johnson", Age=30}, {Name="Alice Brown", Age=28}}),
  FilterList = List.FindText(Data[Name], "Alice"),
  Result = Table.SelectRows(Data, each List.Contains(FilterList, [Name]))
in
  Result
```

**ผลลัพธ์:** `ตารางที่มีแค่ Alice Smith และ Alice Brown`

ใช้ List.FindText เพื่อหา Names ที่มี 'Alice' แล้วใช้กรอง Table - ประโยชน์มากเวลาข้อมูลใหญ่

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

- ผมแนะนำให้ใช้ Text.Lower ก่อนถ้าต้องการให้ Case Insensitive: List.FindText(List.Transform(myList, Text.Lower), Text.Lower(searchText))

- ส่วนตัวผม ชอบใช้กับ Table.SelectRows เพื่อกรองตารางตามเงื่อนไขข้อความ ประสิทธิภาพดีและ Code ชัดเจน

- ถ้าต้องการ Wildcard pattern ลองใช้ List.FindText ร่วมกับ Text.Contains สำหรับ Control มากขึ้น

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

**Q: List.FindText เป็น Case Sensitive หรือไม่?**

เป็น Case Sensitive ครับ ผม test ดูแล้ว List.FindText({"Apple", "apple"}, "apple") จะได้แค่ {"apple"} ไม่จับ "Apple" ถ้าต้องไม่สนใจตัวพิมพ์ใหญ่/เล็ก ต้องใช้ Text.Lower กับทั้ง List และ Text

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

ผมชี้แจงนะ - List.Contains เป็นการหา Exact Match พอดีๆ (หรือเกือบพอดี) ส่วน List.FindText เป็นการหา Substring Match (ค้นหาข้อความย่อยภายใน) ดังนั้น List.FindText ยืดหยุ่นกว่า

**Q: ถ้า List ว่างหรือ Text ว่างจะเกิดอะไร?**

ถ้า List ว่าง จะได้ List ว่าง ถ้า Text ว่าง ผมเดาว่าจะได้ List เต็มทั้งหมด (เพราะทุกข้อความมี Empty String อยู่) ลองเองดีที่สุด

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

- [List.Select – เลือกสมาชิกจาก List ตามเงื่อนไข](https://www.thepexcel.com/functions/power-query/list-functions/list-select/)
- [Text.Contains – ตรวจสอบว่าข้อความมีส่วนประกอบที่ต้องการหรือไม่](https://www.thepexcel.com/functions/power-query/text-functions/text-contains/)

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

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

---

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