# Building Sum Aggregate fields based on calculated fields

**URL:** <https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595>\
**Category:** Classic Servoy\
**Created:** [March 30, 2004, 3:44pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595 "2004-03-30T15:44:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DFehrenbach](https://avatars.discourse-cdn.com/v4/letter/d/c67d28/32.png) [@DFehrenbach](https://forum.servoy.com/u/DFehrenbach)\
**Post date:** [March 30, 2004, 3:44pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595/1 "2004-03-30T15:44:10Z")

</div>

I have a table with the following two number fields:  
feeamt  
expenseamt

and a calculated field:  
cbillamt = return (feeamt + expenseamt)

Now, I want to create an aggregate field: sumBillamt to be the sum of cbillamt.

Since cbillamt was not in the list of fields, I made it a stored calculation and created the aggregation based on that stored calc field.

The calculated field is correct, however, the amount returned in the aggregate field is not correct.  
Am I going about this in the correct way?

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [April 5, 2004, 5:49pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595/2 "2004-04-05T17:49:53Z")

</div>

confirmed.

After a search,  
total seems to equal only first record total.  
Ater clicking into second record, aggregate updates corrrectly.

Will pass to dev team.  
Thanks.

---

<div class="post-metadata">

**Author:** ![jmeunier](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jmeunier](https://forum.servoy.com/u/jmeunier)\
**Post date:** [April 25, 2006, 3:17pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595/3 "2006-04-25T15:17:53Z")

</div>

Has this been fixed? If so, what version. I am trying to sum a stored calc field and it is not working.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [April 25, 2006, 7:53pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595/4 "2006-04-25T19:53:44Z")

</div>

That must be! Or else I have BIG problem with my customers! ![:lol:]( "Laughing")

Can you describe what is going wrong??

---

<div class="post-metadata">

**Author:** ![jmeunier](https://avatars.discourse-cdn.com/v4/letter/j/5e9695/32.png) [@jmeunier](https://forum.servoy.com/u/jmeunier)\
**Post date:** [April 25, 2006, 7:58pm UTC](https://forum.servoy.com/t/building-sum-aggregate-fields-based-on-calculated-fields/1595/5 "2006-04-25T19:58:08Z")

</div>

I found my problem.

I created the caculation field first in Servoy (because I wanted to try it unstored first), then created a database field with the same name in MySQL. When I went back to Servoy, the calc field was already clicked as stored. The database field was not being updated correctly, even though the stored box was checked in Servoy. I deleted the calc field and recreated the stored calc using the dropdown and it worked just fine after that.

Sorry for any confusion…

Thanks,  
Jason
