แปลงอักษรตัวแรกของทุกคำเป็นตัวพิมพ์ใหญ่ (Title Case) และส่วนที่เหลือเป็นตัวพิมพ์เล็ก
=Text.Proper(text as nullable text, optional culture as nullable text) as nullable text
=Text.Proper(text as nullable text, optional culture as nullable text) as nullable text
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| text | text | Yes | ข้อความต้นฉบับ (nullable text) ที่ต้องการแปลงเป็น Title Case | |
| culture | text | Optional | null | รหัสภาษา (culture code) เช่น “en-US” หรือ “th-TH” สำหรับใช้กฎการแปลงอักษรตามภาษาที่ระบุ ถ้าไม่ระบุจะใช้ culture เริ่มต้นของระบบ |
Text.Proper("john doe")= Text.Proper("john doe")
"John Doe"
Text.Proper("tHE QUICK BrOWn fOx")= Text.Proper("tHE QUICK BrOWn fOx")
"The Quick Brown Fox"
Text.Proper("laptop computer 15 inch hd display")= Text.Proper("laptop computer 15 inch hd display")
"Laptop Computer 15 Inch Hd Display"
Table.TransformColumns( Source, {{"CustomerName", each Text.Proper(_), type text}} )= Table.TransformColumns(
Source,
{{"CustomerName", each Text.Proper(_), type text}}
)
ทุกชื่อใน CustomerName column จะถูกแปลงเป็น Title Case (เช่น "john smith" -> "John Smith")
ตัวเลขจะไม่เปลี่ยนแปลง Text.Proper จะเปลี่ยนแค่ตัวอักษรเท่านั้น เช่น “product 2024” จะกลายเป็น “Product 2024”
ถ้า input text เป็น null ผลลัพธ์ก็จะเป็น null ด้วย ไม่มี error
Text.Proper ถือว่าเครื่องหมายวรรค (comma, period, apostrophe) และช่องว่างเป็นตัวแยกคำ เช่น “it’s here” จะกลายเป็น “It’S Here” ลักษณะนี้ต้องระวัง
culture parameter ใช้สำหรับระบุกฎการแปลงอักษรตามภาษา เช่น “en-US” สำหรับอังกฤษ “th-TH” สำหรับไทย โดยแต่ละภาษามี rule ของตัวเองในการแปลงอักษร
ฟังก์ชัน Text.Proper(text, optional culture) ใช้สำหรับแปลงข้อความให้เป็นรูปแบบ Title Case โดยตัวแรกของแต่ละคำจะเป็นตัวพิมพ์ใหญ่และตัวอักษรที่เหลือจะเป็นตัวพิมพ์เล็ก ส่งกลับค่า Text
ที่เจ๋งคือ Text.Proper ทำให้เรา normalize ชื่อหรือข้อมูล text ที่ยุ่งๆ มาในรูปแบบสม่ำเสมอ เหมาะสำหรับ data cleaning โดยเฉพาะตอนจัดการชื่อคน ชื่อสถาน หรือหัวข้อที่ผู้ใช้พิมพ์มาแบบไม่เป็นระเบียบ
ส่วนตัวผม มักใช้ Text.Proper กับ Table.TransformColumns เพื่อ standardize ชื่อในหลายคอลัมน์พร้อมกัน ตัวอักษรจะแน่นอนและสะอาดขึ้นเยอะเลย