---
title: Number.From – แปลงค่าเป็นตัวเลข
url: https://www.thepexcel.com/functions/power-query/number-functions/number-from/
type: function-explainer
program: Power Query
syntax: "Number.From(value as any, optional culture as nullable text) as nullable number"
date: 2025-12-03
updated: 2025-12-23
scores:
  popularity: 7
  difficulty: 2
  usefulness: 7
---

# Number.From – แปลงค่าเป็นตัวเลข

> Number.From จะพยายามแปลงค่า Input ให้เป็น Number หากเป็น Text จะพยายาม Parse ตัวเลขออกมา หากเป็น Dat

## คำอธิบาย

Number.From จะพยายามแปลงค่า Input ให้เป็น Number หากเป็น Text จะพยายาม Parse ตัวเลขออกมา หากเป็น Date/Time จะแปลงเป็น Serial Number (เช่นเดียวกับ Excel)

## Syntax

```excel
Number.From(value as any, optional culture as nullable text) as nullable number
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| value | Yes | any |  | ค่าที่ต้องการแปลงเป็นตัวเลข สามารถเป็น Text, Date, Time, Logical, Duration หรือ Number เดิม |
| culture | No | text | null | รหัสวัฒนธรรม (Culture Code) เช่น "en-US" หรือ "th-TH" มีผลต่อการแปลทศนิยมและหลักพัน (en-US ใช้ . คั่นทศนิยม และ , คั่นหลักพัน ส่วน de-DE ใช้สวนกลับ) |

## เคสการใช้งาน

### แปลงข้อความเป็นตัวเลข

แปลง "123.45" ให้เป็นตัวเลข 123.45 เพื่อนำไปคำนวณ

### แปลงวันที่เป็น Serial Number

แปลงค่า Date ให้เป็นตัวเลข (เช่น 45658) เพื่อใช้ในการคำนวณทางคณิตศาสตร์

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: แปลงข้อความตัวเลข

```excel
= Number.From("123.45")
```

**ผลลัพธ์:** `123.45`

แปลงข้อความ "123.45" เป็นตัวเลข 123.45

### 2. ตัวอย่างที่ 2: แปลงวันที่เป็น Serial Number

```excel
= Number.From(#date(2020, 3, 20))
```

**ผลลัพธ์:** `43910`

แปลงวันที่ 20 มีนาคม 2020 เป็น Serial Number แบบ Excel (วันที่ 1 ต่อเทศกาล)

### 3. ตัวอย่างที่ 3: ใช้ Culture Parameter

```excel
= Number.From("1.234,56", "de-DE")
```

**ผลลัพธ์:** `1234.56`

แปลงข้อความรูปแบบเยอรมัน (ใช้ . คั่นพัน และ , คั่นทศนิยม) ให้เป็นตัวเลข 1234.56

### 4. ตัวอย่างที่ 4: แปลง Logical Value

```excel
= Number.From(true)
```

**ผลลัพธ์:** `1`

แปลง true เป็น 1 และ false เป็น 0

### 5. ตัวอย่างที่ 5: แปลงเวลาเป็น Fractional Day

```excel
= Number.From(#time(12, 0, 0))
```

**ผลลัพธ์:** `0.5`

แปลงเวลา 12:00:00 เป็น 0.5 (ครึ่งวัน)

### 6. ตัวอย่างที่ 6: ใช้กับ try-otherwise เพื่อจัดการ Error

```excel
let
    Source = Table.FromRows({{"100"}, {"abc"}, {"50.5"}}, {"Value"}),
    Converted = Table.AddColumn(Source, "NumValue", each try Number.From([Value]) otherwise null)
in
    Converted
```

**ผลลัพธ์:** `ตารางแสดง Value 100 และ 50.5 เป็น Number, abc เป็น null`

ใช้ try-otherwise เพื่อแปลงข้อความเป็นตัวเลข ถ้าแปลงไม่ได้จะกลับเป็น null แทนที่จะ Error

## หมายเหตุเพิ่มเติม

- ใช้ Number.From คู่กับ try-otherwise เพื่อจัดการข้อมูลที่อาจแปลงไม่ได้

- ถ้าข้อมูลมาจากประเทศต่างๆ ให้ระบุ Culture Parameter เสมอ

- Number.From(true) = 1 และ Number.From(false) = 0 มีประโยชน์ในการแปลง Logical เป็น Number สำหรับการคำนวณ

- เมื่อแปลง Date/Time เป็น Number ได้ค่า Decimal แสดงว่าเป็น Fractional Day ซึ่งใช้ได้กับ Excel

## คำถามที่พบบ่อย

**Q: Number.From ต่างจาก Number.FromText อย่างไร?**

Number.FromText ใช้ได้เฉพาะกับ Text เท่านั้น แต่ Number.From ใช้กับค่าประเภทอื่นได้ด้วย (เช่น Date, Time, Logical, Duration) ถ้าค่าเป็น Text แล้วต้องการตัวเลือกเฉพาะ Text จะใช้ Number.FromText ได้

**Q: ถ้าแปลงไม่ได้จะเกิดอะไร?**

ปกติ Number.From จะ Return Error ถ้าข้อมูลไม่สามารถแปลงได้ ดังนั้นควรใช้ try-otherwise เพื่อจัดการ Error

**Q: Culture Parameter มีความสำคัญแค่ไหน?**

สำคัญมาก หากข้อมูลใช้รูปแบบ Culture ที่ต่างจาก Default (en-US) ต้องระบุ Culture หรือจะแปลงค่าผิด เช่น "1.000,50" ในเยอรมัน คือ 1000.50 แต่ถ้าไม่ระบุ Culture อาจแปลงเป็น 1.00050

**Q: Date/Time แปลงเป็น Number ได้ยังไง?**

Power Query ใช้ OLE Automation Date System คล้ายกับ Excel โดยนับจำนวนวันตั้งแต่ 1 มกราคม ค.ศ. 1900 สำหรับ Date และ Fractional Day สำหรับ Time

## ฟังก์ชันที่เกี่ยวข้อง

- [Number.FromText – แปลงข้อความเป็นตัวเลข](https://www.thepexcel.com/functions/power-query/number-functions/number-fromtext/)
- [Number.ToText – แปลงตัวเลขเป็นข้อความ](https://www.thepexcel.com/functions/power-query/number-functions/number-totext/)
- [Date.From – แปลงข้อมูลต่างประเภทเป็นวันที่](https://www.thepexcel.com/functions/power-query/date-functions/date-from/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Number.From](https://learn.microsoft.com/en-us/powerquery-m/number-from) _(official)_
- [PowerQuery.how](https://powerquery.how/number-from/) _(article)_
- [Microsoft Learn: Number Types](https://learn.microsoft.com/en-us/powerquery-m/number-type) _(official)_

---

_Source: [https://www.thepexcel.com/functions/power-query/number-functions/number-from/](https://www.thepexcel.com/functions/power-query/number-functions/number-from/)_
