ตัวอย่างที่ 1: ตรวจสอบการลงท้าย
=Text.EndsWith("apple", "ple")
true
เช็คว่าข้อความหลักลงท้ายด้วยข้อความย่อยที่กำหนดหรือไม่
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
=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 |
เลือกเฉพาะไฟล์ที่ลงท้ายด้วย ".xlsx" หรือ ".csv"
ถ้าข้อความในคอลัมน์ลงท้ายด้วย "_Final" ให้ถือว่าเป็นรายงานฉบับสมบูรณ์
=Text.EndsWith("apple", "ple")
true
=Text.EndsWith("banana", "nan")
false
=Text.EndsWith("Excel", "cel", Comparer.OrdinalIgnoreCase)
true
เป็น Case Sensitive ครับ เช่น Text.EndsWith(“Excel”, “cel”) จะได้ false ถ้าต้องการไม่สนใจ Case ต้องใช้ Comparer.OrdinalIgnoreCase
ฟังก์ชัน Text.EndsWith ใน Power Query ใช้สำหรับตรวจสอบว่าข้อความหลัก ลงท้ายด้วยข้อความย่อย (Substring) ที่กำหนดหรือไม่ โดยจะคืนค่าเป็น true หากใช่ และ false หากไม่ใช่