---
# System prepended metadata

title: 'Excel Week 3 - Conditional, Logical, Error Function'
tags: [Excel]

---

# Excel Week 3 - Conditional, Logical, Error Function
###### tags: `Excel`

## 目錄
[Excel Week 2 - Cell References](/Y89sQy8VSn6OeJZwvt7Slg)
[Excel Week 3 - Conditional, Logical, Error Function](/L1QFm4HfQSqxlNW61Q4jEQ)
[Excel Week 4 - TRUE & FALSE, Operators](/7v5CuDH8Ri-YN3xAVyhKgA)
[Excel Week 4 - Statistical Functions](/PTR8Q-PmS7mJ9mBPEVi-dA)
[Excel Week 5 - Statistical + Conditional / Logical Functions](/uqi1U5xFSqSZ_nJbk-KiMQ)
[Excel Week 6 - Lookup & References](/AqLoNRtJRIWbEFyh6W2DaQ)

## TRUE & FALSE
**TRUE**
- 非0數值
- 邏輯值為TRUE

**FALSE**
- 0
- 邏輯值為FALSE
- 空值(blank)

![](https://i.imgur.com/QjGSyB9.png =70%x)

### Special Return Value
#### TRUE :
:::danger
- 「 TRUE 」
- 「 =TRUE 」
- 「 =TRUE() 」
- 「 ="TRUE" 」
:::
#### OTHER :
:::danger
- 「 」(space) : only blank is false, space is #VALUE!
- 「 ="1" 」「 ="0" 」: except for 「 ="TRUE" 」, all texts are #VALUE!
:::
#### WHAT'S MORE :
:::danger
&emsp; However, **「 TRUE 」==「 =TRUE() 」!=「 ="TRUE" 」**
&emsp; Since the first two are **boolean** and **boolean function**, and the third one is **text**.
:::

## Transform between Types
**NUMBER**
- TRUE = 1, FALSE = 0
- TRUE+0 = 1, FALSE+0 = 0

**TEXT**
- TRUE = "TRUE", FALSE = "FALSE"
:::danger
&emsp; 不同類別不等值（NUM(TRUE) = 1 != "TRUE"）
:::

![](https://i.imgur.com/FC3y6UJ.png =60%x)

## 比較運算子
- 等於 ＝
- 不等於 <>

判斷是否為空值：ISBLANK()

## Conditional Functions
### IF()
- IF(boolean, ouput if TRUE, output if FALSE)
- IF(C3>=60, "及格", "不及格")

### IFS()
- IFS(陳述1, 輸出值1, 陳述2, 輸出值2, ...)
- IFS(E3>=90, "A", E3>=80, "B", ...)
- 依序判斷所有邏輯陳述，回傳**首個**為真的對應輸出

### SWITCH()
- SWITCH(要替換的欄位, 選項1, 替換值1, 選項2, 替換值2, ...)
- SWITCH(D2, "January", "一月", "February", "二月", ...)

## Logical Functions
### AND()
- 至少一個為假，則輸出FALSE

### OR()
- 至少一個為真，則輸出TRUE

### NOT()
- yeap.

### XOR()
- TRUE數量單數回傳TRUE，偶數回傳FALSE

## 錯誤訊息
### #N/A :
- **搜尋** 時找不到目標欄位
### #VALUE!：
- 運算子或值類別錯誤
- **5+abc**
### #REF! :
- 刪除儲存格後沒有更新參照位置，找不到指定的 **(舊)參照位置**
### #DIV/0! :
- **除數為 0**
### #NUM! :
- 不符規則的無效值
- **0 取對數**
### #NAME? :
- **函數文法** 錯誤
### #NULL! :
- **範圍**參照位置為空集合

## 錯誤訊息 Functions
### IFERROR()
- IFERROR(值, 若錯誤時回傳的值)
### IFNA()
- IFNA(值, 若值#N/A則回傳的值)
- IFNA(VLOOKUP("C", D:E, 2, FALSE), "找不到C")