# Array formula summation is not correct

**URL:** <https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983>\
**Category:** Ask for Help\
**Created:** [October 12, 2021, 5:38pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983 "2021-10-12T17:38:56Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 12, 2021, 5:38pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/1 "2021-10-12T17:38:56Z")

</div>

Hi  
I have a problem with an array formula, where the amount in the “SALDO” column is not true.

I want the correct amount as in the “SALDO YANG BENAR” column

the formula I use in the “SALDO” column is =ArrayFormula(IF(J3:J="";"";M2+K3:K-L3:L))

the formula I use in the column “SALDO YANG BENAR” is =N2+K3-L3

Is there a solution for the problem I’m facing?

I attached a screenshot

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/0/90b6f1b8b141451634909a3f83350f9af3f9086d.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 12, 2021, 6:24pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/2 "2021-10-12T18:24:36Z")

</div>

Shouldn’t you be using M2:M instead of M2?

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 12, 2021, 6:44pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/3 "2021-10-12T18:44:14Z")

</div>

thank you for your response.I’ve tried it, but when I try it, I get a pop up “Interdependence is detected. To finish with iterative calculations, see File \> Spreadsheet Settings.”  
I attached a screenshot…

 ![Screenshot_2021-10-13-01-38-05-625_com.google.android.apps.docs.editors.sheets](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/a/5a608e6378a526d342d159b07f29873f68bf35bc.jpeg)

---

<div class="post-metadata">

**Author:** ![spencerb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/spencerb/32/4486_2.png) [@spencerb](https://community.glideapps.com/u/spencerb)\
**Post date:** [October 12, 2021, 6:48pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/4 "2021-10-12T18:48:53Z")

</div>

Shouldn’t it be…

```auto
=arrayformula(if(J3:J="",,M2:M+K3:K-L3:L))

```

I guess the semicolons are because you’re in a different country? But, just wondering why you have another set of double quotes. I always put double commas after the one set of double quotes.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 12, 2021, 7:11pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/5 "2021-10-12T19:11:42Z")

</div>

Arrayformulas in google sheets get complicated when you start referring to values in different rows. I’ve done it before, but you need to add some extra checks to make sure you are not referring to a row that does not exist at the beginning or end of your data. Personally I would approach this much differently and just build all logic in Glide. For something like this, I would either use rollups to sum credits and debits and use a math column to get a final total, or for each new transaction, I would get the last balance prior to adding the new transaction, and pass that value through the form.

Do you really need a running balance on each row? Would you ever edit an existing transaction?

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 12, 2021, 11:11pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/6 "2021-10-12T23:11:17Z")

</div>

@Jeff_Hager  
I have made a rollup to get the final amount of each transaction made, how do I pass the final value through the form and print it on my google sheet…?

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

---

<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:** [October 12, 2021, 11:18pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/7 "2021-10-12T23:18:29Z")

</div>

You should be able to do that using a screen column in your form, write that to the column you want in the destination sheet.

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 12, 2021, 11:44pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/8 "2021-10-12T23:44:03Z")

</div>

@ThinhDinh  
I named the final sum result in Glide with the name “SUM SALDO”  
but i don’t find the screen column with the name “SUM SALDO”  
how do i add to the form?

 ![Capture](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/3/7375e8f6030951b95730685fb5a03b5cb7885880.png)

screen column 👇

 ![Capturem](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/f/df621034bbd56f3b4290ae94a6e9ac297d62cd18.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 12, 2021, 11:52pm UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/9 "2021-10-12T23:52:00Z")

</div>

If your form is located on the profile, then you will need that rollup and sum on the profile table so you can pull it into the form. The screen values components in a form come from whichever table is the source of the tab or details screen that contains the form button.

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 13, 2021, 12:02am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/10 "2021-10-13T00:02:24Z")

</div>

@Jeff_Hager  
because my rollup data is in “JURNAL” I tried to create a new form and put it in “JURNAL”, but I still can’t find it…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/5/a55ffa5aa742b40173bde8c368079b97ca784c0e.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 13, 2021, 12:04am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/11 "2021-10-13T00:04:06Z")

</div>

You need to add a component on the left hand side. Your column will be one of the available components.

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 13, 2021, 12:45am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/12 "2021-10-13T00:45:02Z")

</div>

@Jeff_Hager  
Is it like this? 👇

 ![Capture](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/b/9b8854cba2b0a80213129ec4a969f0cd3dcfeef1.png)

I’ve tried it, but the sum is not what I expected,  
the final result should be IDR 5,483,900 + IDR 1,000,000 = IDR 6,483,900  
but the data printed on my google sheet is IDR 5,483,900

 ![Screenshot (241)](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/1/91c2cfbe6827220cb8f39575ddab9093e5b6a2ae.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 13, 2021, 3:07am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/13 "2021-10-13T03:07:26Z")

</div>

First of all, I would think you would want to only pass the previous sum through the form. It should be passed to a ‘previous sum’ column. You shouldn’t be passing the rollup columns because you are only using them to calculate the sum from all entries prior to the form submit, and besides, it appears that you are requiring entry of a debit or credit…so there is no reason to pass any debits or credits from the rollup columns through the form.

You would still need to do some math to add or subtract the new credit or debit from the previous sum to get the new sum. It’s getting confusing because you want the final sum to be in the sheet. I would just calculate it in glide, but I’m not sure if there is a reason that you need that total in the sheet instead bof a glide computed column.

Just to be clear, a form will not perform any math. The math can only happen once the data is written to a table or a sheet.

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 13, 2021, 3:32am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/14 "2021-10-13T03:32:10Z")

</div>

@Jeff_Hager  
my reason for adding it in google sheet for data analysis needs…

---

<div class="post-metadata">

**Author:** ![agung\_Taufik](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/agung_taufik/32/2589_2.png) [@agung\_Taufik](https://community.glideapps.com/u/agung_Taufik)\
**Post date:** [October 13, 2021, 3:34am UTC](https://community.glideapps.com/t/array-formula-summation-is-not-correct/32983/15 "2021-10-13T03:34:30Z")

</div>

Well…  
Thanks for all the help…
