---
title: List.PositionOf – หาตำแหน่งของสมาชิกใน List
url: https://www.thepexcel.com/functions/power-query/list-functions/list-positionof/
type: function-explainer
program: Power Query
syntax: "List.PositionOf(list as list, value as any, optional occurrence as nullable number, optional comparer as nullable function) as any"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# List.PositionOf – หาตำแหน่งของสมาชิกใน List

> หาตำแหน่ง Index ของสมาชิกใน List

## คำอธิบาย

List.PositionOf จะคืนค่า Index แรกสุด (0-based) ของ value ที่พบใน list ถ้าไม่พบจะคืนค่า -1 สามารถระบุ occurrence เพื่อหาตำแหน่งของตัวที่ซ้ำกัน และใช้ comparer เพื่อกำหนดวิธีการเปรียบเทียบ (Case Sensitive/Insensitive)

## Syntax

```excel
List.PositionOf(list as list, value as any, optional occurrence as nullable number, optional comparer as nullable function) as any
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ที่ต้องการค้นหา |
| value | Yes | any |  | ค่าที่ต้องการค้นหาใน List |
| occurrence | No | number | 0 | ตำแหน่งที่ต้องการหา (0=ตัวแรก, 1=ตัวที่สอง, ...) |
| comparer | No | function | null | ฟังก์ชัน Comparer สำหรับกำหนดวิธีการเปรียบเทียบ |

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

### ตรวจสอบลำดับสินค้า

หาว่าสินค้าชิ้นนี้อยู่ลำดับที่เท่าไหร่ในรายการสั่งซื้อ

### ใช้กับ Text.Split

เมื่อ Text.Split แยกข้อความเป็น List แล้ว สามารถหาตำแหน่งของคำบางคำได้

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: หาตำแหน่งสมาชิก

```excel
List.PositionOf({"A", "B", "C"}, "B")
```

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

"B" อยู่ตำแหน่ง Index ที่ 1 (เริ่มนับจาก 0)

### 2. ตัวอย่างที่ 2: หาตำแหน่งที่ไม่พบ

```excel
List.PositionOf({"A", "B", "C"}, "D")
```

**ผลลัพธ์:** `-1`

ไม่พบ "D" ใน List จึงคืนค่า -1

### 3. ตัวอย่างที่ 3: หาตำแหน่งตัวที่สอง

```excel
List.PositionOf({"A", "B", "A", "C"}, "A", 1)
```

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

หา "A" ตัวที่สอง ซึ่งอยู่ตำแหน่ง Index ที่ 2

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

**Q: Index 0-based คืออะไร?**

หมายถึงการนับตำแหน่งเริ่มต้นที่ 0 ไม่ใช่ 1 เหมือน Excel Worksheet Function เช่น สมาชิกตัวแรกอยู่ Index 0, ตัวที่สองอยู่ Index 1

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

- [List.PositionOfAny – หาตำแหน่งของค่าใดค่าหนึ่ง](https://www.thepexcel.com/functions/power-query/list-functions/list-positionofany/)
- [Text.PositionOf – หาตำแหน่งข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-positionof/)

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

- [Microsoft Learn: List.PositionOf](https://learn.microsoft.com/en-us/powerquery-m/list-positionof) _(Official Documentation)_
- [PowerQuery.how](https://powerquery.how/list-positionof/) _(guide)_

---

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