---
title: List.Range – ดึงช่วงของสมาชิกจาก List
url: https://www.thepexcel.com/functions/power-query/list-functions/list-range/
type: function-explainer
program: Power Query
syntax: "List.Range(list as list, offset as number, optional count as nullable number) as list"
date: 2025-12-12
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# List.Range – ดึงช่วงของสมาชิกจาก List

> ดึงช่วงของสมาชิกจาก List โดยระบุตำแหน่งเริ่มต้นและจำนวน

## คำอธิบาย

List.Range ดึงช่วงของสมาชิกจาก List โดยระบุตำแหน่งเริ่มต้น (offset) และจำนวนสมาชิกที่ต้องการดึง ฟังก์ชันนี้มีประโยชน์เมื่อต้องการดึงข้อมูลชุดย่อยจากตำแหน่งใดๆ ในรายการ

## Syntax

```excel
List.Range(list as list, offset as number, optional count as nullable number) as list
```

**Variant**

```excel
List.Range(list, 2, 3)
```

ดึง 3 สมาชิกเริ่มจากตำแหน่ง 2 (ตำแหน่ง 0 คือตำแหน่งแรก)

**Variant**

```excel
List.Range(list, 5)
```

ดึงสมาชิกทั้งหมดตั้งแต่ตำแหน่ง 5 ไปถึงสุดท้าย

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | รายการที่ต้องการดึงช่วงของสมาชิก |
| offset | Yes | number |  | ตำแหน่งเริ่มต้น (0 คือตำแหน่งแรก) |
| count | No | nullable number | null | จำนวนสมาชิกที่ต้องการดึง (ถ้าไม่ระบุจะดึงไปจนสุดท้าย) |

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

### ดึงข้อมูลหน้าสินค้า

ดึงสินค้า 10 รายการต่อหน้า โดยเลือกหน้าที่ 3 (สมาชิกจากตำแหน่ง 20-29)

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

### ตัดส่วนนำ/ปิดท้ายของรายการ

ดึงข้อมูลจากตำแหน่งกลางของรายการ โดยข้ามหัวและท้าย

_เหมาะกับ:_ data-slicing

## ตัวอย่าง

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

```excel
List.Range({10, 20, 30, 40, 50}, 1, 3)
```

**ผลลัพธ์:** `{20, 30, 40}`

ดึงจากตำแหน่ง 1 จำนวน 3 สมาชิก ได้ 20, 30, และ 40

### 2. ตัวอย่างที่ 2: ดึงจากตำแหน่ง 2 ไปจนสุดท้าย

```excel
List.Range({"Apple", "Banana", "Cherry", "Date"}, 2)
```

**ผลลัพธ์:** `{"Cherry", "Date"}`

ดึงจากตำแหน่ง 2 (Cherry) ไปจนสุดท้าย ได้ Cherry และ Date

### 3. ตัวอย่างที่ 3: แสดงหน้า 2 (รายการ 5-9)

```excel
let
    AllNumbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
    PageSize = 5,
    PageNumber = 2,
    StartPosition = (PageNumber - 1) * PageSize,
    Page2 = List.Range(AllNumbers, StartPosition, PageSize)
in
    Page2
```

**ผลลัพธ์:** `{6, 7, 8, 9, 10}`

คำนวณตำแหน่งเริ่มต้นของหน้า 2 (ตำแหน่ง 5) และดึง 5 รายการ ได้รายการ 6-10

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

⚠️ ข้อสังเกต: การนับตำแหน่งเริ่มจาก 0 ดังนั้นตำแหน่งแรกคือ 0 ไม่ใช่ 1 ตรวจสอบ offset ให้ถูกต้องเพื่อหลีกเลี่ยงข้อผิดพลาด

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

**Q: ความแตกต่างระหว่าง List.Range กับ List.FirstN คืออะไร**

List.FirstN ดึงจากจุดเริ่มต้นเท่านั้น ส่วน List.Range สามารถดึงจากตำแหน่งใดๆ ในรายการ

**Q: ถ้า offset มากกว่าจำนวนสมาชิก จะเกิดอะไร**

ฟังก์ชันจะคืนรายการว่างเปล่า เพราะตำแหน่งเริ่มต้นอยู่นอกช่วงของรายการ

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

- [List.FirstN – ดึงสมาชิก N ตัวแรกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-firstn/)
- [List.LastN – ดึงสมาชิก N ตัวท้ายจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-lastn/)
- [List.Skip – ข้ามสมาชิก N ตัวแรกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-skip/)

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

- [Microsoft Learn: List.Range](https://learn.microsoft.com/en-us/powerquery-m/list-range) _(documentation)_

---

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