# Multiple criteria sumif array formula with logic

**URL:** <https://community.glideapps.com/t/multiple-criteria-sumif-array-formula-with-logic/9155>\
**Category:** Ask for Help\
**Created:** [May 14, 2020, 7:07pm UTC](https://community.glideapps.com/t/multiple-criteria-sumif-array-formula-with-logic/9155 "2020-05-14T19:07:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 15, 2020, 4:38am UTC](https://community.glideapps.com/t/multiple-criteria-sumif-array-formula-with-logic/9155/3 "2020-05-15T04:38:42Z")

</div>

Ok I’m back with what seems to work.

Firstly, ArrayFormula does not work with SUMIFS, or QUERY. It would have been such easier tasks had it been that way.

I have worked with many people who want to implement ARRAYFORMULA into their work so that automatic calculation can be applied whenever there’s a new row. Recently I faced the same problem when working on a logic with @Robert_Petitto and wrote a little script as a workaround, I will have a single post for this later so it can be used as a reference for future problems.

Ok so here’s the setup:

- Sender ID
- Receiver ID
- Amount send
- Sender balance (before transaction)
- Confirm if transaction can happen

Scripts, formula and settings:

- A script to automatically copy down the formula in column D when a new row is generated.
- 3 rows of assigning initial bank balance (100) to 3 IDs (marked as green).
- A QUERY formula to calculate the cumulative bank balance for ID in question by the logic: (Sum of all amount receive so far) - (Sum of all amount send so far), in cases where transactions marked as TRUE (can happen).
- File \> Spreadsheet Settings \> Turn on iterative calculation.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/d/d0e5c35a4d56dbdb0542488861e4a01252b22deb.png)

Demo:

![ezgif-1-d7ce61d2e30c](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/b/bc9edf7a780663f12c1fc597d01e4804ad6a03f9.gif)

Link to the spreadsheet: [https://docs.google.com/spreadsheets/d/1sEQHpSKyHx9w2F\_Xx3lm56SU1p-8eI81OYU5TYvQFvw/edit#gid=1848555900](https://docs.google.com/spreadsheets/d/1sEQHpSKyHx9w2F_Xx3lm56SU1p-8eI81OYU5TYvQFvw/edit#gid=1848555900)

---

_[View the full topic](https://community.glideapps.com/t/multiple-criteria-sumif-array-formula-with-logic/9155)._
