---
title: AGGREGATE – คำนวณแบบละเว้น Error และแถวที่ซ่อน
url: https://www.thepexcel.com/functions/excel/math-and-trigonometry/aggregate/
type: function-explainer
program: Excel
syntax: "=AGGREGATE(function_num, options, ref1, [ref2], ...)"
date: 2025-12-02
updated: 2025-12-23
scores:
  popularity: 6
  difficulty: 3
  usefulness: 7
---

# AGGREGATE – คำนวณแบบละเว้น Error และแถวที่ซ่อน

> AGGREGATE เป็นฟังก์ชันสารพัดประโยชน์ที่รวม 19 ฟังก์ชันต่างๆ (SUM, AVERAGE, COUNT, MAX, MIN ฯลฯ) แต่ม

## คำอธิบาย

AGGREGATE เป็นฟังก์ชันสารพัดประโยชน์ที่รวม 19 ฟังก์ชันต่างๆ (SUM, AVERAGE, COUNT, MAX, MIN ฯลฯ) แต่มีความสามารถพิเศษคือ สามารถข้าม Error ได้ และข้ามแถวที่ถูกซ่อน (Hidden Rows) ได้ เหมาะสำหรับ Dashboard, รายงาน หรือข้อมูลที่อาจมีช่องว่างและข้อมูลผิดพลาด

## Syntax

```excel
=AGGREGATE(function_num, options, ref1, [ref2], ...)
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| function_num | Yes | Number (1-19) |  | รหัสของฟังก์ชันที่ต้องการใช้: 1=AVERAGE, 2=COUNT, 3=COUNTA, 4=MAX, 5=MIN, 6=PRODUCT, 7=STDEV, 8=STDEVP, 9=SUM, 10=VAR, 11=VARP, 12=MEDIAN, 13=MODE, 14=LARGE, 15=SMALL, 16=PERCENTILE, 17=QUARTILE, 18=RANK, 19=AGGREGATE |
| options | Yes | Number (0-7) |  | ตัวเลือกการข้าม: 0=ไม่ข้ามอะไร แต่ข้าม SUBTOTAL/AGGREGATE nested, 1=ข้ามแถวที่ซ่อน + nested functions, 2=ข้ามแถวต่างๆ (ใช้ไม่ได้), 3=ข้าม hidden rows + error values, 4=ไม่ข้ามอะไรเลย, 5=ข้ามแถวที่ซ่อนเท่านั้น, 6=ข้าม error values เท่านั้น, 7=ข้าม hidden rows + error values |
| ref1 | Yes | Range / Array |  | ช่วงข้อมูลแรกที่ต้องการคำนวณ เช่น A1:A10 หรือ Sales[Amount] |
| ref2 | No | Range / Array |  | ช่วงข้อมูลที่สอง (ถ้าฟังก์ชันต้องการ 2 ref เช่น Subtotal reference form) - บางฟังก์ชันเช่น LARGE, SMALL, PERCENTILE, QUARTILE ต้องมี ref2 เพื่อระบุตำแหน่ง k |

## ตัวอย่าง

### 1. หาผลรวมโดยข้าม Error (SUM + Ignore Error)

```excel
=AGGREGATE(9, 6, A2:A10)
```

**ผลลัพธ์:** `ผลรวมของค่าตัวเลขทั้งหมดในช่วง A2:A10 ไม่รวม Error`

function_num=9 หมายถึง SUM, options=6 หมายถึงข้าม error values เท่านั้น - ดีเมื่อข้อมูลมี #DIV/0! หรือ #N/A ในบางช่อง ฟังก์ชัน SUM ปกติจะคืน error แต่ AGGREGATE จะคำนวณเฉพาะที่ปกติ

### 2. นับจำนวนแบบไม่นับแถวที่ซ่อน (COUNT + Ignore Hidden)

```excel
=AGGREGATE(2, 5, B2:B100)
```

**ผลลัพธ์:** `จำนวนแถวที่ไม่ว่างใน B2:B100 (ไม่นับแถวที่ถูก Filter ออก)`

function_num=2 คือ COUNT, options=5 คือ ignore hidden rows - ใช้เมื่อคุณกรอง (Filter) ข้อมูล คุณต้องการนับเฉพาะแถวที่แสดง ไม่ใช่แถวทั้งหมดของตาราง

### 3. หาค่ามากสุดอันดับ 2 (LARGE + Ignore Error)

```excel
=AGGREGATE(14, 6, Salary[Amount], 2)
```

**ผลลัพธ์:** `ค่าเงินเดือนมากสุดลำดับที่ 2`

function_num=14 คือ LARGE, ref2=2 คือหา 2 ตัวมากสุด, options=6 คือข้าม error - เหมาะสำหรับหา Top N values พร้อมกับจัดการ error ในตารางเดียว

### 4. หาค่าเฉลี่ย พร้อมข้ามแถวที่ซ่อน + Error (AVERAGE + Ignore Hidden + Error)

```excel
=AGGREGATE(1, 7, D2:D50)
```

**ผลลัพธ์:** `ค่าเฉลี่ยของเฉพาะแถวที่แสดง (ไม่ซ่อนและไม่ error)`

function_num=1 คือ AVERAGE, options=7 คือข้าม hidden rows AND error values - ใช้สำหรับ Dashboard ที่มีการ Filter ข้อมูลอยู่เสมอ

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

- ใช้ Table[Column] notation (เช่น Sales[Amount]) แทน A1:A10 จะทำให้ range อัพเดต automatic เมื่อเพิ่มแถวใหม่

- สำหรับ Dashboard ที่มี Filter บ่อย ใช้ options=5 (ignore hidden rows) เพื่อให้ผลลัพธ์แสดงเฉพาะที่ visible

- ถ้ามี Error ในข้อมูล ใช้ options=6 หรือ 7 แล้วค่อยหา root cause ของ error นั้นๆ แล้วแก้ที่ source

- ฟังก์ชัน function_num=19 (AGGREGATE ตัวเอง) ใช้สำหรับ nested AGGREGATE แล้ว ignore nested functions ด้วย

- อย่าใช้ AGGREGATE ใหญ่โต บนข้อมูล Millions rows - อาจช้า ลองใช้ SUBTOTAL ก่อน

- ใช้ร่วมกับ FILTER ได้ดี เช่น =AGGREGATE(9, 6, FILTER(Data, Condition)) เพื่อหาผลรวมของเฉพาะแถวที่ตรงเงื่อนไข

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

**Q: AGGREGATE vs SUBTOTAL ต่างกันยังไง?**

SUBTOTAL ข้าม hidden rows ได้ (11 ฟังก์ชัน) แต่ AGGREGATE เก่งกว่าเพราะข้าม error ได้ด้วย และมี 19 ฟังก์ชัน ไม่ว่าจะ LARGE, SMALL, PERCENTILE ที่ SUBTOTAL ไม่มี

**Q: options=0 กับ options=4 ต่างกันยังไง?**

options=0 ข้าม nested SUBTOTAL/AGGREGATE แต่ยังข้าม error, options=4 ไม่ข้ามอะไร (รวม error, nested functions ทั้งหมด)

**Q: ใช้ได้กับ Excel เวอร์ชันไหน?**

AGGREGATE มีอยู่ตั้งแต่ Excel 2010 ขึ้นไป ทั้ง Windows, Mac และ Excel 365

**Q: function_num เลขอะไร คือ SUM?**

function_num=9 คือ SUM, ลองดูตาราง function_num ด้านบน

**Q: AGGREGATE จะ recalculate ทุกครั้งที่ Filter หรือเปลี่ยนข้อมูลไหม?**

ใช่ AGGREGATE recalculate automatic เมื่อ ref1/ref2 เปลี่ยน หรือเมื่อซ่อน/แสดงแถว

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

- [AVERAGE – หาค่าเฉลี่ยของตัวเลข](https://www.thepexcel.com/functions/excel/statistical/average/)
- [COUNT – ฟังก์ชันนับจำนวนตัวเลข](https://www.thepexcel.com/functions/excel/statistical/count/)
- [FILTER – ฟังก์ชันกรองข้อมูลแบบไดนามิก](https://www.thepexcel.com/functions/excel/lookup-and-reference/filter/)
- [LARGE – หาค่าที่มากที่สุดเป็นอันดับที่ต้องการ (k)](https://www.thepexcel.com/functions/excel/statistical/large/)
- [SUBTOTAL – คำนวณผลรวมย่อยพร้อม Filter](https://www.thepexcel.com/functions/excel/math-and-trigonometry/subtotal/)
- [SUM – ฟังก์ชันรวมตัวเลข](https://www.thepexcel.com/functions/excel/math-and-trigonometry/sum/)

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

- [Microsoft Official Docs - AGGREGATE](https://support.microsoft.com/en-us/office/aggregate-function-43b9278e-6aa7-4f17-92b6-e19993fa26df) _(official)_
- [Microsoft Docs - Function Numbers Reference](https://support.microsoft.com/en-us/office/aggregate-function-73eae1f7-383a-4166-9da9-ead07598c901) _(official)_

---

_Source: [https://www.thepexcel.com/functions/excel/math-and-trigonometry/aggregate/](https://www.thepexcel.com/functions/excel/math-and-trigonometry/aggregate/)_
