---
title: SEARCH – ค้นหาตำแหน่งข้อความ (ไม่สนตัวพิมพ์) ใน DAX
url: https://www.thepexcel.com/functions/dax/text/search-dax/
type: function-explainer
program: DAX
syntax: "SEARCH(find_text, within_text, [start_position])"
date: 2025-12-14
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# SEARCH – ค้นหาตำแหน่งข้อความ (ไม่สนตัวพิมพ์) ใน DAX

> ค้นหาตำแหน่งข้อความย่อย (case-insensitive)

## คำอธิบาย

SEARCH คืนค่าตำแหน่งเริ่มต้นของข้อความที่ค้นหา (ค้นหาแบบไม่สนตัวพิมพ์) หากไม่พบจะเกิดข้อผิดพลาด สามารถใช้กับ IFERROR หรือ COALESCE เพื่อจัดการกรณีไม่พบ

## Syntax

```excel
SEARCH(find_text, within_text, [start_position])
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| find_text | Yes | text |  | ข้อความที่ต้องการค้นหา |
| within_text | Yes | text |  | ข้อความต้นทางที่ต้องการค้นหา find_text |
| start_position | No | integer |  | ตำแหน่งเริ่มค้นหา (นับจาก 1) ถ้าไม่ระบุจะเริ่มจากต้นสตริง |

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

### กรองข้อความตามคีย์เวิร์ด

ใช้ SEARCH เพื่อตรวจสอบว่าชื่อสินค้าหรือคำอธิบายมีคีย์เวิร์ดสำคัญหรือไม่ ก่อนกรองในรายงาน

_เหมาะกับ:_ keyword-filtering

### จัดหมวดตามรหัส

ค้นหาส่วนของรหัสที่สื่อความหมาย (เช่น "VIP", "STD") แล้วสร้างคอลัมน์/Measure จัดกลุ่มตามค่าที่พบ

_เหมาะกับ:_ code-classification

### ทำ Indicator สำหรับเงื่อนไข

สร้างคอลัมน์ boolean จาก SEARCH เพื่อติดธงแถวที่ตรงเงื่อนไข เช่น มีคำว่า "urgent" หรือไม่

_เหมาะกับ:_ flagging

## ตัวอย่าง

### 1. หาตำแหน่งคีย์เวิร์ดในคำอธิบาย

```excel
Keyword Pos = SEARCH("organic", Products[Description])
```

**ผลลัพธ์:** `ตำแหน่งเริ่มต้นของคำว่า "organic" หรือ error หากไม่พบ`

ใช้ค้นหาคำว่า organic โดยไม่สนตัวพิมพ์ ช่วยบอกว่ามีคำนี้อยู่ในข้อความหรือไม่

### 2. สร้างตัวบ่งชี้มี/ไม่มีคีย์เวิร์ด

```excel
Is Promo = NOT ISERROR( SEARCH("promo", Products[Description]) )
```

**ผลลัพธ์:** `TRUE หากพบคำว่า promo, FALSE หากไม่พบ`

ใช้ ISERROR จับข้อผิดพลาดเมื่อไม่พบข้อความ แล้วกลับค่าเป็น TRUE/FALSE สำหรับการกรองหรือจัดกลุ่ม

### 3. จัดหมวดตามรหัสที่ซ่อนอยู่ในข้อความ

```excel
Tier = 
VAR pos = SEARCH("VIP", Customers[Notes])
RETURN IF( NOT ISERROR(pos), "VIP", "Standard")
```

**ผลลัพธ์:** `"VIP" หรือ "Standard"`

ค้นหาแท็ก VIP ในคอลัมน์หมายเหตุ ถ้าพบจัดเป็น VIP ไม่พบถือเป็น Standard เหมาะกับการทำ segmentation แบบง่าย

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

**Q: ต่างจาก FIND อย่างไร?**

SEARCH ไม่สนใจตัวพิมพ์ใหญ่-เล็ก ส่วน FIND สนใจตัวพิมพ์ จึงเลือกใช้ตามความต้องการ

**Q: ถ้าไม่พบข้อความจะได้ผลลัพธ์อะไร?**

จะได้ error ควรห่อด้วย IFERROR หรือ ISERROR เพื่อตรวจสอบและจัดการผลลัพธ์

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

- [FIND – หาตำแหน่งข้อความ (แบบแยกตัวพิมพ์ใหญ่/เล็ก)](https://www.thepexcel.com/functions/dax/text/find-dax/)
- [SUBSTITUTE – แทนที่ข้อความที่ตรงกัน](https://www.thepexcel.com/functions/dax/text/substitute-dax/)
- [REPLACE – แทนที่ข้อความบางส่วน (DAX)](https://www.thepexcel.com/functions/dax/text/replace-dax/)
- [LEN (DAX) – นับจำนวนอักขระในข้อความ](https://www.thepexcel.com/functions/dax/text/len-dax/)
- [EXACT – เปรียบเทียบข้อความแบบตรงตัว (คำนึงตัวพิมพ์เล็ก/ใหญ่)](https://www.thepexcel.com/functions/dax/text/exact-dax/)
- [UPPER – แปลงข้อความเป็นตัวพิมพ์ใหญ่ทั้งหมด](https://www.thepexcel.com/functions/dax/text/upper-dax/)
- [LOWER – แปลงเป็นตัวพิมพ์เล็ก](https://www.thepexcel.com/functions/dax/text/lower-dax/)
- [COALESCE – คืนค่าแรกที่ไม่เป็น BLANK()](https://www.thepexcel.com/functions/dax/logical/coalesce-dax/)
- iserror-dax
- [IFERROR – คืนค่าแทนเมื่อเกิดข้อผิดพลาด](https://www.thepexcel.com/functions/dax/logical/iferror-dax/)

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

- [DAX Guide: SEARCH](https://dax.guide/search/) _(documentation)_
- [Microsoft Learn: SEARCH](https://learn.microsoft.com/en-us/dax/search-function-dax) _(documentation)_

---

_Source: [https://www.thepexcel.com/functions/dax/text/search-dax/](https://www.thepexcel.com/functions/dax/text/search-dax/)_
