---
title: Text.TrimEnd – ลบช่องว่างหรืออักขระส่วนท้าย
url: https://www.thepexcel.com/functions/power-query/text-functions/text-trimend/
type: function-explainer
program: Power Query
syntax: "Text.TrimEnd(text as nullable text, optional trimChars as nullable list) as nullable text"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# Text.TrimEnd – ลบช่องว่างหรืออักขระส่วนท้าย

> ลบช่องว่างหรืออักขระส่วนเกินที่อยู่ด้านท้ายข้อความ

## คำอธิบาย

Text.TrimEnd จะลบช่องว่างหรืออักขระส่วนเกินที่อยู่ด้านขวาสุดของข้อความออก สามารถระบุ List ของอักขระที่ต้องการลบได้ เป็นเครื่องมือที่ดีในการทำความสะอาดข้อมูลที่ Copy มาแล้วมี Space หรือสัญลักษณ์ต่อท้ายเกินมา

## Syntax

```excel
Text.TrimEnd(text as nullable text, optional trimChars as nullable list) as nullable text
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | text |  | ข้อความที่ต้องการลบอักขระส่วนเกินด้านท้าย |
| trimChars | No | list | Space character | List ของอักขระที่ต้องการลบ (ถ้าไม่ระบุ จะลบ Space) |

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

### ทำความสะอาดรหัสสินค้า

เมื่อรหัสสินค้ามีช่องว่างต่อท้าย ทำให้ VLOOKUP หาไม่เจอ หรือดูไม่สวยงาม

### ลบสัญลักษณ์ต่อท้าย

ลบเครื่องหมาย (-) หรือ (*) ที่อาจต่อท้าย ID หรือชื่อไฟล์

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ลบช่องว่างต่อท้าย

```excel
Text.TrimEnd("  apple   ")
```

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

ลบเฉพาะช่องว่าง 3 เคาะที่อยู่ท้ายคำว่า "apple" ช่องว่างหน้าคำยังคงอยู่

### 2. ตัวอย่างที่ 2: ลบอักขระต่อท้าย

```excel
Text.TrimEnd("###text###", {"#"})
```

**ผลลัพธ์:** `###text`

ลบเฉพาะเครื่องหมาย # ที่อยู่ท้ายข้อความออก

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

**Q: Text.TrimEnd ต่างจาก Text.Trim อย่างไร?**

Text.TrimEnd ลบเฉพาะส่วนท้าย Text.Trim ลบทั้งหน้าและหลัง

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

- [Text.Trim – ตัดอักขระนำหน้าและลงท้าย](https://www.thepexcel.com/functions/power-query/text-functions/text-trim/)
- [Text.TrimStart – ลบช่องว่างหรืออักขระเริ่มต้น](https://www.thepexcel.com/functions/power-query/text-functions/text-trimstart/)

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

- [Microsoft Learn: Text.TrimEnd](https://learn.microsoft.com/en-us/powerquery-m/text-trimend) _(Official Documentation)_
- [PowerQuery.how](https://powerquery.how/text-trimend/) _(guide)_

---

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