Text.Lower ใช้แปลงอักขระทั้งหมดในข้อความให้เป็นตัวพิมพ์เล็ก (lowercase) ช่วยให้ข้อมูลมีรูปแบบสอดคล้องกัน สามารถกำหนด Culture เพื่อให้การแปลงเป็นไปตามกฎของภาษาและภูมิภาคที่ต้องการ
=Text.Lower(text as nullable text, optional culture as nullable text) as nullable text
=Text.Lower(text as nullable text, optional culture as nullable text) as nullable text
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| text | text | Yes | ข้อความที่ต้องการแปลงเป็นตัวพิมพ์เล็ก | |
| culture | text | Optional | null | รหัสวัฒนธรรม (เช่น “en-US”, “th-TH”, “tr-TR”) เพื่อให้การแปลงเป็นไปตามกฎของภาษานั้นๆ หากไม่ระบุจะใช้ Culture เริ่มต้นของระบบ |
แปลงชื่อสินค้า หรือรหัสสินค้าให้เป็นตัวพิมพ์เล็กทั้งหมดเพื่อหลีกเลี่ยงปัญหาการจับคู่ข้อมูลที่แตกต่างกันด้วยตัวพิมพ์เล็ก/ใหญ่
กำหนดให้ข้อมูลในบางคอลัมน์ต้องเป็นตัวพิมพ์เล็กเสมอ เช่น ชื่อคีย์เวิร์ด
ใช้แปลงข้อความเป็นตัวพิมพ์เล็กทั้งหมดก่อนนำไปเปรียบเทียบ เพื่อให้ไม่สนใจความแตกต่างของ Case Sensitive
Text.Lower("HELLO WORLD")= Text.Lower("HELLO WORLD")
hello world
Text.Lower("ApPLe PiE 123")= Text.Lower("ApPLe PiE 123")
apple pie 123
let Products = Table.FromRows( {{"iPhone", 1200}, {"SAMSUNG", 900}, {"Sony", 800}}, {"Brand", "Price"} ), LowerBrand = Table.AddColumn(Products, "LowerBrand", e…let
Products = Table.FromRows(
{{"iPhone", 1200}, {"SAMSUNG", 900}, {"Sony", 800}},
{"Brand", "Price"}
),
LowerBrand = Table.AddColumn(Products, "LowerBrand", each Text.Lower([Brand]))
in
LowerBrand
Table with 3 rows: {"iphone", "samsung", "sony"}
let Email1 = "John.Doe@example.com", Email2 = "JOHN.DOE@EXAMPLE.COM", AreEqual = Text.Lower(Email1) = Text.Lower(Email2) in AreEquallet
Email1 = "John.Doe@example.com",
Email2 = "JOHN.DOE@EXAMPLE.COM",
AreEqual = Text.Lower(Email1) = Text.Lower(Email2)
in
AreEqual
true
let Turkish = "İstanbul", DefaultLower = Text.Lower(Turkish), TurkishLower = Text.Lower(Turkish, "tr-TR") in {DefaultLower, TurkishLower}let
Turkish = "İstanbul",
DefaultLower = Text.Lower(Turkish),
TurkishLower = Text.Lower(Turkish, "tr-TR")
in
{DefaultLower, TurkishLower}
{"i̇stanbul", "istanbul"}
หลักการทำงานเหมือนกัน แต่ Text.Lower ใช้ใน Power Query M Language ส่วน LOWER() ใช้ใน Excel Worksheet Function นอกจากนี้ Text.Lower ยังรองรับ culture parameter เพิ่มเติมอีก
ได้ null กลับมาครับ Text.Lower รองรับ nullable text ดังนั้นหากข้อมูลเป็น null จะคืนค่า null โดยไม่เกิด error
ได้ครับ Text.Lower จะแปลงเฉพาะตัวอักษร (a-z, A-Z) ส่วนตัวเลขและ special characters จะคงเดิม ไม่เปลี่ยนแปลง
จะใช้ Culture เริ่มต้นของระบบแทนครับ โดยทั่วไปจะเป็น “en-US” ถ้าต้องการการแปลงตามกฎของภาษาอื่น ให้ระบุ culture code อย่างชัดเจนเสมอ
Text.Lower เป็นฟังก์ชันทำความสะอาดข้อมูล (Data Cleaning) ที่ใช้สำหรับแปลงตัวอักษรทั้งหมดในข้อความให้เป็นตัวพิมพ์เล็ก
ที่เจ๋งคือ Text.Lower ช่วยให้เราสามารถทำการเปรียบเทียบข้อมูลแบบไม่สนใจตัวพิมพ์เล็ก/ใหญ่ (case-insensitive comparison) ได้ง่ายมาก เหมาะมากเวลาต้องจับคู่ข้อมูลจาก 2 source ที่เขียนแบบไม่เหมือนกัน
ส่วนตัวผมใช้ Text.Lower คู่กับ Table.SelectRows บ่อยมากครับ เพื่อทำให้การกรองข้อมูลนั้นไม่ไวต่อขนาดตัวอักษร ซึ่งช่วยให้เหลือความผิดพลาดที่เกิดจากตัวอักษรตัวใหญ่/เล็ก 😎