---
title: "how to sum up the numbers from a group"
url: "https://openforis.support/questions/1559/how-to-sum-up-the-numbers-from-a-group"
tags: ["collect"]
status: "accepted"
score: 0
answer_count: 3
asked: "2018-01-04T11:57:39"
last_activity: "2018-01-05T14:39:47"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# how to sum up the numbers from a group

Asked by beka on 2018-01-04

Hi Open Foris Team,
I have a question - Can you please explain to me how to sum up the numbers in the following case: 
If I have the case like this: 
1
1
2
2
2
2
3
3
3
4
5
5
And I want to add one representative of each number group (e.i. 1+2+3+4+5)

Thanks in advance


## Accepted answer (score 1, by Stefano (OF) on 2018-01-05)

Link: https://openforis.support/questions/1559/how-to-sum-up-the-numbers-from-a-group/1566

Hi Beka,  
Sorry, you are right, the expression won't work in this case.  
We will add an extra custom `math:sum` function that can be used in this case, it will be available in version 3.21 of Collect (it will be released next week).  
Thanks again,  
Open Foris Team


## Answer (score 1, by Stefano (OF) on 2018-01-05)

Link: https://openforis.support/questions/1559/how-to-sum-up-the-numbers-from-a-group/1563

Hi Beka,  
You can use an expression like this:  
`sum(idm:distinct-values(list_of_values))`  
where `list_of_values` can be provided as a multiple attribute or as an attribute inside a multiple entity, so your final expression can be:  
`sum(idm:distinct-values(entity_name/attribute_name))`  

Many thanks,  
Open Foris Team

> Thank you very much. I tried expression like this: sum(idm:distinct-values(parent()/tree/sum_basal_area1)) And after preview, when I press "tree" Entity, the error message appears. https://drive.google.com/drive/folders/1FUcehn5Js3LBH3w-gG9876MI-S8Yq4DM?usp=sharing (beka)

## Answer (score 0, by beka on 2018-01-05)

Link: https://openforis.support/questions/1559/how-to-sum-up-the-numbers-from-a-group/1565

Thank you very much. I tried expression like this:
sum(idm:distinct-values(parent()/tree/sum_basal_area1))

And after preview, when I press "tree" Entity, the error message appears.

https://drive.google.com/drive/folders/1FUcehn5Js3LBH3w-gG9876MI-S8Yq4DM?usp=sharing
