---
title: Text.Start – ดึงอักขระจากตัวแรกของข้อความ
url: https://www.thepexcel.com/functions/power-query/text-functions/text-start/
type: function-explainer
program: Power Query
syntax: "Text.Start(text as nullable text, count as number) as nullable text"
date: 2025-12-04
updated: 2025-12-23
scores:
  popularity: 7
  difficulty: 2
  usefulness: 7
---

# Text.Start – ดึงอักขระจากตัวแรกของข้อความ

> Text.Start ดึงอักขระจำนวนที่กำหนดจากตัวแรกของสตริงข้อความ ใช้สำหรับดึงชื่อย่อ รหัส หรือส่วนแรกของข้อ

## คำอธิบาย

Text.Start ดึงอักขระจำนวนที่กำหนดจากตัวแรกของสตริงข้อความ ใช้สำหรับดึงชื่อย่อ รหัส หรือส่วนแรกของข้อมูล

## Syntax

```excel
Text.Start(text as nullable text, count as number) as nullable text
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| text | Yes | nullable text |  | ข้อความต้นฉบับที่ต้องการดึงอักขระ |
| count | Yes | number |  | จำนวนอักขระที่ต้องการดึงจากตัวแรก (ต้องเป็นจำนวนเต็มบวก) |

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

### ดึงชื่อสกุลหรือ initials

ดึงชื่อสกุลหรือ initials

### ดึงรหัสประเภทหรือ prefix

ดึงรหัสประเภทหรือ prefix

### สกัดชื่อหรือรหัสจากข้อมูลเต็ม

สกัดชื่อหรือรหัสจากข้อมูลเต็ม

## ตัวอย่าง

### 1. ดึง 5 ตัวแรกจากข้อความ

```excel
= Text.Start("Hello, World!", 5)
```

**ผลลัพธ์:** `"Hello"`

ดึงอักขระ 5 ตัวแรกจากข้อความ 'Hello, World!' ได้ 'Hello' (นับว่างด้วยครับ)

### 2. ดึง Prefix จากรหัสสินค้า

```excel
let
    ProductCodes = {"TX-2025-001", "NY-2025-002", "CA-2025-003"},
    GetCategory = List.Transform(ProductCodes, each Text.Start(_, 2))
in
    GetCategory
```

**ผลลัพธ์:** `{"TX", "NY", "CA"}`

ดึง 2 ตัวแรกจากรหัสสินค้า เป็น category (TX, NY, CA) ใช้ List.Transform แล้วลูป each ตัวอักขระ

### 3. สร้าง Email Address จากชื่อ-สกุล

```excel
let
    People = Table.FromRows({{"Douglas", "Elis"}, {"Ana", "Jorayew"}}, {"FirstName", "LastName"}),
    WithEmail = Table.AddColumn(People, "Email", each Text.Combine({Text.Start([FirstName], 4), Text.Start([LastName], 3), "@contoso.com"}))
in
    WithEmail
```

**ผลลัพธ์:** `Table with column Email = {"DougEli@contoso.com", "AnaJor@contoso.com"}`

สร้าง email โดยดึง 4 ตัวแรกของชื่อ + 3 ตัวแรกของสกุล + domain ใช้ Text.Combine รวมสตริง

### 4. ดึง Month Code จากวันที่

```excel
let
    Dates = {"2025-01-15", "2025-02-20", "2025-03-10"},
    MonthCodes = List.Transform(Dates, each "M-" & Text.Start(_, 7))
in
    MonthCodes
```

**ผลลัพธ์:** `{"M-2025-01", "M-2025-02", "M-2025-03"}`

ดึง 7 ตัวแรกจากวันที่ (ปี-เดือน) แล้วเพิ่ม 'M-' นำหน้า เอาไว้ใช้เป็น Month Code

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

- ใช้ Text.Start กับ List.Transform เพื่อดึง prefix จากหลายแถว เร็วกว่าทำครั้งละแถว

- ดึง prefix แล้ว combine กับ suffix (Text.End) ได้ชุด format ที่ต้องการ เช่น "AB...XY"

- ใช้ในตัวกำหนดเงื่อนไข Filter เช่น Table.SelectRows(data, each Text.Start([Code], 2) = "TX") ได้ครับ

- ถ้าต้องดึงหลายส่วน เช่น 3 ตัวแรก 5 ตัวกลาง 2 ตัวท้าย ใช้ Text.Start + Text.Range + Text.End ร่วมกัน

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

**Q: จะเกิดอะไรถ้า count มากกว่าความยาวของข้อความ?**

ถ้า count มากกว่าความยาวของข้อความ ฟังก์ชันจะคืนค่าข้อความทั้งหมด เช่น Text.Start("Hi", 10) ก็คืน "Hi" ครับ

**Q: Text.Start จะนับเว้นวรรค (space) ด้วยหรือไม่?**

ใช่ครับ เว้นวรรคจะนับเป็นอักขระ 1 ตัว เช่น Text.Start("Hello World", 6) = "Hello " (มี space)

**Q: ความแตกต่างระหว่าง Text.Start และ Text.Range คืออะไร?**

Text.Start ดึงจากตัวแรก แต่ Text.Range ดึงจากตำแหน่งใดก็ได้ ถ้าอยากเริ่มจาก index 3 ต้องใช้ Text.Range

**Q: ถ้าข้อความเป็น null จะเกิดอะไร?**

ถ้าข้อความเป็น null ฟังก์ชันจะคืนค่า null ป้อง error ทั้งนี้ต้องเช็คด้วย each [Column]  null ก่อนครับ

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

- [Microsoft Learn: Text.Start](https://learn.microsoft.com/en-us/powerquery-m/text-start) _(official)_
- [Power Query How - Text Functions](https://powerquery.how) _(article)_

---

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