Thep Excel

Text.EndsWith – ตรวจสอบว่าลงท้ายด้วยข้อความย่อยหรือไม่

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

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

=Text.EndsWith(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.EndsWith(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

กรองข้อมูลตามนามสกุลไฟล์

เลือกเฉพาะไฟล์ที่ลงท้ายด้วย ".xlsx" หรือ ".csv"

จัดหมวดหมู่ข้อมูล

ถ้าข้อความในคอลัมน์ลงท้ายด้วย "_Final" ให้ถือว่าเป็นรายงานฉบับสมบูรณ์

Examples

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

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

=Text.EndsWith("apple", "ple")

Result:

true

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

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

=Text.EndsWith("banana", "nan")

Result:

false

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

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

=Text.EndsWith("Excel", "cel", Comparer.OrdinalIgnoreCase)

Result:

true

FAQs

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

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

Resources & Related

Additional Notes

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

Leave a Reply

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