# Updating calculations based on aggregations

**URL:** <https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534>\
**Category:** Classic Servoy\
**Created:** [March 21, 2004, 6:22pm UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534 "2004-03-21T18:22:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [March 21, 2004, 6:22pm UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534/1 "2004-03-21T18:22:03Z")

</div>

I put the following fields in a table:  
expense\_amount (number)  
cash\_expense\_amount

```auto
if
(
 payment_method == "Cash" ||
 type == "Cash deposit ||
 type == "Checks deposit"
)
{
return expense_amount
}

```

bank\_expense\_amount

```auto
if
(
 payment_method == "Check" 
)
{
return expense_amount
}

```

tot\_cash\_expense\_amount, aggregate SUM(cash\_expense\_amount)  
tot\_bank\_expense\_amount, aggregate SUM(bank\_expense\_amount)  
tot\_expenses

```auto
return tot_cash_expense_amount +tot_bank_expense_amount;

```

If I put the form in List view and I perform a search, the aggregates field update correctly, but tot\_expenses doesn’t. All the calcs are stored.  
I also tried to put the fields in a Grand Summary, but I get the same behaviour…

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [March 21, 2004, 6:37pm UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534/2 "2004-03-21T18:37:45Z")

</div>

Hai Riccardino,

I would really like to help you but often I ‘stop right after starting’. I am lazy and get really confused by all italian words since I don’t understand italian.

Would it be possible for you to do such posting in english so I (and maybe others) can concentrate on the issue…

But ok, does a controller.saveData() help you?

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [March 21, 2004, 6:59pm UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534/3 "2004-03-21T18:59:47Z")

</div>

> IT2BE:  
> Hai Riccardino,
> 
> I would really like to help you but often I ‘stop right after starting’. I am lazy and get really confused by all italian words since I don’t understand italian.
> 
> Would it be possible for you to do such posting in english so I (and maybe others) can concentrate on the issue…

You’re right. I didn’t think about translating because the calc field containing those formulas don’t seem to have problems. I’ll translate the previous message…

BTW: saving data doesn’t change the result.

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [March 23, 2004, 11:05am UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534/4 "2004-03-23T11:05:20Z")

</div>

Update: the calcs seem to update if a loop thru the records. It seems that even jumping to last record forces the update. Is this an expected behaviour?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [March 23, 2004, 2:54pm UTC](https://forum.servoy.com/t/updating-calculations-based-on-aggregations/1534/5 "2004-03-23T14:54:34Z")

</div>

this should work fine with the latest releases (8 and 9) so i don’t get how the calc still doesn’t recalculate itself. CAn you send me an example?
