Thep Excel

Text.StartsWith – ตรวจสอบว่าขึ้นต้นด้วยข้อความย่อยหรือไม่

เช็คว่าข้อความหลักขึ้นต้นด้วยข้อความย่อยที่กำหนดหรือไม่

Text.StartsWith จะคืนค่า true หาก text หลักขึ้นต้นด้วย substring ที่กำหนด และคืนค่า false หากไม่ตรงกัน สามารถระบุ Comparer เพื่อกำหนดว่าจะให้ตรวจสอบแบบ Case Sensitive หรือ Case Insensitive ได้

=Text.StartsWith(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=Text.StartsWith(text as nullable text, substring as text, optional comparer as nullable function) as nullable logical

Argument Type Required Default Description
text text Yes ข้อความหลักที่ต้องการตรวจสอบ
substring text Yes ข้อความย่อยที่ต้องการตรวจสอบการขึ้นต้น
comparer function Optional null ฟังก์ชัน Comparer สำหรับการเปรียบเทียบ เช่น Comparer.OrdinalIgnoreCase

How it works

กรองข้อมูลตามรหัสสินค้า

เลือกเฉพาะรายการสินค้าที่รหัสขึ้นต้นด้วย "PROD" หรือ "SKU"

จัดกลุ่มข้อมูลตามหมวดหมู่

ถ้าข้อความในคอลัมน์ขึ้นต้นด้วย "Fruits" ให้จัดอยู่ในหมวดหมู่ผลไม้

Examples

ตัวอย่างที่ 1: ตรวจสอบการขึ้นต้น

ข้อความ "apple" ขึ้นต้นด้วย "app" จึงคืนค่า true
Power Query Formula:

=Text.StartsWith("apple", "app")

Result:

true

ตัวอย่างที่ 2: ไม่ขึ้นต้นด้วยข้อความที่กำหนด

ข้อความ "banana" ไม่ได้ขึ้นต้นด้วย "app" จึงคืนค่า false
Power Query Formula:

=Text.StartsWith("banana", "app")

Result:

false

ตัวอย่างที่ 3: ไม่สนใจตัวพิมพ์เล็ก/ใหญ่

Comparer.OrdinalIgnoreCase ทำให้ไม่สนใจ Case Sensitive
Power Query Formula:

=Text.StartsWith("Apple", "app", Comparer.OrdinalIgnoreCase)

Result:

true

FAQs

Text.StartsWith เป็น Case Sensitive หรือไม่?

เป็น Case Sensitive ครับ เช่น Text.StartsWith(“Apple”, “app”) จะได้ false ถ้าต้องการไม่สนใจ Case ต้องใช้ Comparer.OrdinalIgnoreCase

Resources & Related

Additional Notes

ฟังก์ชัน Text.StartsWith ใน Power Query ใช้สำหรับตรวจสอบว่าข้อความหลัก ขึ้นต้นด้วยข้อความย่อย (Substring) ที่กำหนดหรือไม่ โดยจะคืนค่าเป็น true หากใช่ และ false หากไม่ใช่

Leave a Reply

Your email address will not be published. Required fields are marked *