---
title: Text.PadStart – เติมอักขระด้านหน้า
url: https://www.thepexcel.com/functions/power-query/text-functions/text-padstart/
type: function-explainer
program: Power Query
syntax: "Text.PadStart(text as nullable text, count as number, optional character as nullable text) as nullable text"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# Text.PadStart – เติมอักขระด้านหน้า

> เติมอักขระด้านหน้าข้อความให้ครบตามจำนวนหลัก

## คำอธิบาย

Text.PadStart จะเพิ่มอักขระที่ระบุ (เช่น '0' หรือ '-') เข้าไปด้านหน้าของข้อความ จนกว่าความยาวของข้อความนั้นจะถึงจำนวนหลักที่ต้องการ ใช้ในการจัดรูปแบบข้อมูลให้สม่ำเสมอ หรือนำไปใช้กับ Sort ได้อย่างถูกต้อง

## Syntax

```excel
Text.PadStart(text as nullable text, count as number, optional character as nullable text) as nullable text
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | text |  | ข้อความที่ต้องการเติมอักขระ |
| count | Yes | number |  | จำนวนหลักของข้อความที่ต้องการให้เป็น |
| character | No | text | Space | อักขระที่ต้องการเติม (ถ้าไม่ระบุ จะเติม Space) |

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

### เติมเลข 0 นำหน้ารหัส

แปลงรหัสสินค้า "123" ให้เป็น "000123" เพื่อให้มีความยาว 6 หลักเท่ากัน

### จัดเรียงข้อมูล

เมื่อข้อมูลมีความยาวไม่เท่ากัน การเติมอักขระให้เท่ากันจะช่วยให้การเรียงลำดับ (Sort) ถูกต้อง

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: เติมเครื่องหมายขีดกลาง

```excel
Text.PadStart("apple", 8, "-")
```

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

เติมเครื่องหมาย '-' ด้านหน้าคำว่า "apple" จนมีความยาวรวม 8 ตัวอักษร

### 2. ตัวอย่างที่ 2: เติมเลขศูนย์นำหน้า

```excel
Text.PadStart("123", 5, "0")
```

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

เติม '0' ด้านหน้าเลข '123' ให้มีความยาว 5 หลัก

### 3. ตัวอย่างที่ 3: ไม่ระบุอักขระ

```excel
Text.PadStart("apple", 8)
```

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

ถ้าไม่ระบุอักขระที่จะเติม จะเติมด้วยช่องว่าง (Space) โดยอัตโนมัติ

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

**Q: ถ้าข้อความยาวกว่า 'count' จะเป็นอย่างไร?**

ฟังก์ชันจะไม่ทำอะไรกับข้อความครับ จะคืนค่าข้อความเดิมกลับมา

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

- [Text.PadEnd – เติมอักขระด้านหลัง](https://www.thepexcel.com/functions/power-query/text-functions/text-padend/)
- [Text.Repeat – ทำซ้ำข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-repeat/)
- [Text.Trim – ตัดอักขระนำหน้าและลงท้าย](https://www.thepexcel.com/functions/power-query/text-functions/text-trim/)

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

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

---

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