ตัวอย่างที่ 1: แปลงเป็นข้อความธรรมดา
=Number.ToText(123)
"123"
แปลงตัวเลขเป็นข้อความพร้อมจัดรูปแบบ
Number.ToText จะแปลงค่าตัวเลขให้เป็น Text String โดยสามารถระบุ format เพื่อจัดรูปแบบการแสดงผลได้ (เช่น “N2” สำหรับทศนิยม 2 ตำแหน่ง หรือ “C” สำหรับสกุลเงิน) และระบุ culture ได้
=Number.ToText(number as nullable number, optional format as nullable text, optional culture as nullable text) as nullable text
=Number.ToText(number as nullable number, optional format as nullable text, optional culture as nullable text) as nullable text
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| number | number | Yes | ตัวเลขที่ต้องการแปลง | |
| format | text | Optional | null | รูปแบบ (Format String) เช่น “N2”, “C”, “P” |
| culture | text | Optional | null | รหัสวัฒนธรรม (Culture Code) เช่น “en-US” |
แปลง 123.4567 ให้เป็น "123.46" เพื่อแสดงในรายงาน
แปลง 1000 ให้เป็น "$1,000.00" หรือ "฿1,000.00"
=Number.ToText(123)
"123"
=Number.ToText(123.456, "N2")
"123.46"
=Number.ToText(1000, "C", "th-TH")
"฿1,000.00"
N (Number), C (Currency), P (Percentage), E (Scientific), D (Decimal), X (Hexadecimal) และสามารถระบุจำนวนหลักต่อท้ายได้ เช่น N2, P1
ฟังก์ชัน Number.ToText ใน Power Query ใช้สำหรับแปลงตัวเลข (Number) ให้เป็นข้อความ (Text) โดยสามารถกำหนดรูปแบบ (Format) ได้ เช่น ทศนิยม, สกุลเงิน หรือเปอร์เซ็นต์