---
title: Table.PositionOf – หาตำแหน่งของแถว
url: https://www.thepexcel.com/functions/power-query/table-functions/table-positionof/
type: function-explainer
program: Power Query
syntax: "Table.PositionOf(table as table, row as record, optional occurrence as nullable number, optional equationCriteria as any) as any"
date: 2025-12-06
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 4
  usefulness: 5
---

# Table.PositionOf – หาตำแหน่งของแถว

> ค้นหาตำแหน่ง (Index) ของแถวในตาราง

## คำอธิบาย

ค้นหาตำแหน่ง (Index) ของแถวในตาราง

## Syntax

```excel
Table.PositionOf(table as table, row as record, optional occurrence as nullable number, optional equationCriteria as any) as any
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| table | Yes | table |  | ตารางที่ต้องการค้นหา |
| row | Yes | record |  | Record ที่ต้องการค้นหา (แถว) |
| occurrence | No | number | Occurrence.First | ระบุว่าจะหาตัวแรก (Occurrence.First), ตัวสุดท้าย (Occurrence.Last) หรือทั้งหมด (Occurrence.All) |
| equationCriteria | No | any | - | เกณฑ์การเปรียบเทียบ (เช่น "ID" หรือ Comparer.OrdinalIgnoreCase) |

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

### ค้นหา Index ของข้อมูลเพื่อใช้ในการอ้างอิง

ค้นหา Index ของข้อมูลเพื่อใช้ในการอ้างอิง

### ตรวจสอบว่าข้อมูลอยู่ในลำดับที่เท่าไหร่

ตรวจสอบว่าข้อมูลอยู่ในลำดับที่เท่าไหร่

### ใช้ร่วมกับฟังก์ชันอื่นที่ต้องการ Input เป็น Index

ใช้ร่วมกับฟังก์ชันอื่นที่ต้องการ Input เป็น Index

## ตัวอย่าง

### 1. หาตำแหน่งของแถวที่ระบุ (เจอ)

```excel
let
    Source = #table({"ID", "Name"}, {{1, "A"}, {2, "B"}, {3, "C"}}),
    // หาตำแหน่งของแถวที่มี ID=2 และ Name="B"
    Position = Table.PositionOf(Source, [ID=2, Name="B"])
in
    Position
```

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

แถวที่ค้นหาอยู่ที่ Index 1 (คือแถวที่ 2 เพราะเริ่มนับจาก 0)

### 2. หาตำแหน่งของแถวที่ระบุ (ไม่เจอ)

```excel
let
    Source = #table({"ID"}, {{1}, {2}, {3}}),
    Position = Table.PositionOf(Source, [ID=99])
in
    Position
```

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

หากไม่พบข้อมูลที่ตรงกัน จะคืนค่า -1

### 3. หาตำแหน่งทั้งหมด (Occurrence.All)

```excel
let
    Source = #table({"Category"}, {{"A"}, {{"B"}}, {{"A"}}}),
    // หาตำแหน่งของทุกแถวที่เป็น "A"
    Positions = Table.PositionOf(Source, [Category="A"], Occurrence.All)
in
    Positions
```

**ผลลัพธ์:** `{0, 2}`

คืนค่าเป็น List ของตำแหน่งที่เจอทั้งหมด (Index 0 และ 2)

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

- [Table.Contains – จัดการตาราง](https://www.thepexcel.com/?post_type=function-explainer&p=37944)
- [Table.FindText – จัดการตาราง](https://www.thepexcel.com/?post_type=function-explainer&p=37951)
- [List.PositionOf – หาตำแหน่งของสมาชิกใน List](https://www.thepexcel.com/functions/power-query/list-functions/list-positionof/)

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

- [Microsoft Docs](https://learn.microsoft.com/en-us/powerquery-m/table-positionof) _(official)_
- [PowerQuery.how](https://powerquery.how/table-positionof/) _(guide)_

---

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