---
title: List.LastN – ดึงสมาชิก N ตัวท้ายจาก List
url: https://www.thepexcel.com/functions/power-query/list-functions/list-lastn/
type: function-explainer
program: Power Query
syntax: "List.LastN(list as list, count as any) as any"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# List.LastN – ดึงสมาชิก N ตัวท้ายจาก List

> ดึงสมาชิก N ตัวสุดท้าย หรือสมาชิกที่ตรงเงื่อนไขจากด้านท้าย List

## คำอธิบาย

List.LastN จะคืน List ใหม่ที่มีสมาชิก N ตัวสุดท้ายจาก List ต้นฉบับ สามารถระบุจำนวน N ด้วยตัวเลข หรือกำหนดเป็นฟังก์ชันเงื่อนไขเพื่อให้ดึงสมาชิกที่ตรงเงื่อนไขจากจุดสิ้นสุดย้อนกลับไปเรื่อยๆ จนกว่าเงื่อนไขจะไม่เป็นจริง

## Syntax

```excel
List.LastN(list as list, count as any) as any
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ที่ต้องการดึงสมาชิก |
| count | Yes | number/function |  | จำนวนสมาชิกที่ต้องการดึง (ตัวเลข) หรือฟังก์ชันเงื่อนไข (แต่ละ_) |

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

### เลือก 5 อันดับท้ายสุด

เลือกรายการสินค้า 5 อันดับสุดท้ายที่มีมูลค่าต่ำสุด (ใช้ List.Sort ก่อน)

### ตัดท้ายตารางที่ไม่ต้องการ

ถ้าข้อมูลมีบรรทัดที่ไม่ต้องการอยู่ท้ายตาราง สามารถใช้ List.RemoveLastN หรือ List.LastN มาช่วย

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ดึง 2 ตัวสุดท้าย

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

**ผลลัพธ์:** `{"B","C"}`

ดึงสมาชิก 2 ตัวสุดท้ายจาก List

### 2. ตัวอย่างที่ 2: ดึงตามเงื่อนไขจากท้าย

```excel
List.LastN({10, 20, 5, 30}, each _ > 5)
```

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

ดึงสมาชิกจากด้านท้ายตราบใดที่ค่านั้นยังมากกว่า 5 (เมื่อเจอ 20 จะหยุด)

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

**Q: List.LastN กับ Table.LastN ต่างกันอย่างไร?**

List.LastN ใช้กับ List (ข้อมูล 1 มิติ) ส่วน Table.LastN ใช้กับ Table (ข้อมูล 2 มิติ) และคืนค่าเป็น Table

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

- [List.FirstN – ดึงสมาชิก N ตัวแรกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-firstn/)
- [List.Last – คืนค่าสมาชิกตัวสุดท้ายของ List](https://www.thepexcel.com/functions/power-query/list-functions/list-last/)
- [List.RemoveLastN – ลบ N รายการสุดท้าย](https://www.thepexcel.com/functions/power-query/list-functions/list-removelastn/)
- [List.Select – เลือกสมาชิกจาก List ตามเงื่อนไข](https://www.thepexcel.com/functions/power-query/list-functions/list-select/)

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

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

---

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