Question: Please see link below for a sample. Depending on a condition (text) in column A, cell E1 & E2 should auto-populate. This should depend on the condition (text) in column A and total in E5 etc. 

[Google Docs sample](https://docs.google.com/spreadsheets/d/1IbUthijitKFUsdY-eV9upWNcWhP7AvAGRR842WpkWW8/edit?usp=sharing)

Answer: 
**Method 1: use SUMIF()**

Cell E1: `=SUMIF(A5:A,"ORDER",E5:E)`

Cell E2: `=SUMIF(A5:A,"SALE",E5:E)`

---

**Method 2: use SUMIFS()**

Cell E1: `=SUMIFS(E5:E,A5:A,"ORDER")`

Cell E2: `=SUMIFS(E5:E,A5:A,"SALE")`

---

**Method 3: Use SUM() and FILTER()**

Cell E1: `=SUM(FILTER(E5:E,A5:A="ORDER"))`

Cell E2: `=SUM(FILTER(E5:E,A5:A="SALE"))`

---

**Method 4: Use QUERY() for all type in column A**

Cell D1 (need Clear all value in Range D1:E3): `=QUERY(A4:E,"select A,sum(E) where A!='' group by A label A 'Type',sum(E) 'Total'")`

---

> 
> Bonus: in cell E5 you can use ArrayFormula
> 
> 
> 

Cell E5 (need Clear all value in Range E5:E): `=ArrayFormula(IF(A5:A<>"",B5:B*C5:C+D5:D,""))`

**Function References**

* [SUMIF](https://support.google.com/docs/answer/3093583?hl=en)
* [FILTER](https://support.google.com/docs/answer/3093197?hl=en)
* [Query](https://support.google.com/docs/answer/3093343?hl=en)
paste in **E1** cell:

```
={SUMIF(A5:A, "order", E5:E); 
  SUMIF(A5:A, "sale",  E5:E)}

```

[![0](https://i.stack.imgur.com/iBMjO.png)](https://i.stack.imgur.com/iBMjO.png)