---
title: DIVIDE – ฟังก์ชัน DAX
url: https://www.thepexcel.com/functions/dax/math-and-trig/divide-dax/
type: function-explainer
program: DAX
syntax: "DIVIDE(<numerator>, <denominator>, [alternateResult])"
date: 2025-12-14
updated: 2025-12-17
scores:
  popularity: 8
  difficulty: 2
  usefulness: 8
---

# DIVIDE – ฟังก์ชัน DAX

> หารพร้อมกำหนดผลลัพธ์สำรองเมื่อหารด้วยศูนย์

## คำอธิบาย

DIVIDE ทำการหารพร้อม Alternate Result หากตัวหารเป็นศูนย์หรือ BLANK ช่วยให้ Measure ไม่เกิด error และควบคุมค่าที่ต้องการแสดงได้

## Syntax

```excel
DIVIDE(&lt;numerator&gt;, &lt;denominator&gt;, [alternateResult])
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| numerator | Yes | numeric |  | ตัวถูกหาร (ส่วนบน) |
| denominator | Yes | numeric |  | ตัวหาร (ส่วนล่าง) |
| alternateResult | No | numeric or BLANK |  | ค่าที่ต้องการคืนเมื่อหารด้วยศูนย์หรือ BLANK ถ้าไม่ระบุจะคืน BLANK |

## ตัวอย่าง

### 1. หารอย่างปลอดภัยด้วยค่าเริ่มต้นเป็น 0

```excel
Avg Price Safe = DIVIDE( SUM(Sales[Amount]), SUM(Sales[Quantity]), 0 )
```

**ผลลัพธ์:** `ราคาต่อชิ้น หาก Quantity เป็น 0 จะได้ 0`

ป้องกัน error จากการหารด้วยศูนย์ด้วย Alternate Result = 0 ทำให้ Measure แข็งแรงในทุกบริบท

### 2. คำนวณอัตราส่วนพร้อมตัวกรอง

```excel
Return Ratio = 
CALCULATE(
    DIVIDE( SUM(Orders[Returned]), SUM(Orders[Shipped]), BLANK() ),
    Orders[Channel] = "Online"
)
```

**ผลลัพธ์:** `อัตราการคืนสินค้าช่องทาง Online หากไม่มี shipment จะคืน BLANK`

ใช้ CALCULATE ปรับบริบท แล้ว DIVIDE รับมือกรณีตัวหารเป็นศูนย์ เพื่อลดค่าที่ทำให้สับสน

### 3. แปลงเปอร์เซ็นต์กำไรแบบมี Alternate Result

```excel
Margin % = DIVIDE( [Margin Amount], [Revenue], BLANK() )
```

**ผลลัพธ์:** `เปอร์เซ็นต์กำไร หาก Revenue = 0 จะได้ BLANK`

คืน BLANK เมื่อหารไม่ได้ เพื่อลดค่าผิดพลาดจากการแสดงเปอร์เซ็นต์ในกรณีรายได้เป็นศูนย์

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

ใช้ DIVIDE แทนการหารปกติเมื่ออาจเกิดหารด้วยศูนย์ เพื่อควบคุมผลลัพธ์และหลีกเลี่ยง error

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

**Q: ฟังก์ชันนี้ใช้สำหรับอะไร**

DIVIDE ใช้สำหรับการวิเคราะห์

**Q: ต้องส่งข้อมูลอะไร**

ส่งค่าหรือคอลัมน์ข้อมูล

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

- [SUM – รวมค่าตัวเลขจากคอลัมน์ (DAX)](https://www.thepexcel.com/functions/dax/aggregation/sum-dax/)
- [SUMX – Iterator Function สำหรับคำนวณผลรวมแบบ Row-by-Row ใน DAX](https://www.thepexcel.com/functions/dax/aggregation/sumx-dax/)
- [CALCULATE – ฟังก์ชันหลักของ DAX ที่ควบคุม Filter Context](https://www.thepexcel.com/functions/dax/filter/calculate-dax/)
- [FILTER – กรองตารางด้วยเงื่อนไขที่ซับซ้อน (Iterator Function)](https://www.thepexcel.com/functions/dax/filter/filter-dax/)
- [IFERROR – คืนค่าแทนเมื่อเกิดข้อผิดพลาด](https://www.thepexcel.com/functions/dax/logical/iferror-dax/)
- [COALESCE – คืนค่าแรกที่ไม่เป็น BLANK()](https://www.thepexcel.com/functions/dax/logical/coalesce-dax/)

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

- [Microsoft Learn: DAX](https://learn.microsoft.com/en-us/dax/function/divide) _(documentation)_

---

_Source: [https://www.thepexcel.com/functions/dax/math-and-trig/divide-dax/](https://www.thepexcel.com/functions/dax/math-and-trig/divide-dax/)_
