---
title: "Count multiple tree diameters"
url: "https://openforis.support/questions/1481/count-multiple-tree-diameters"
tags: ["collect"]
status: "answered"
score: 0
answer_count: 2
asked: "2017-11-26T12:01:23"
last_activity: "2017-11-28T12:27:21"
source: "Open Foris Support - Q&A Forum"
license: "Copyright Open Foris, 2026. Some rights reserved under creative commons license."
---

# Count multiple tree diameters

Asked by thomas1981 on 2017-11-26

Hi everybody,

I am new to openforis, how can I count multiple tree diameters. eg in a plot I want to count how many trees have a 22cm diameter and each time to add +1 when I find another one in the plot. In the end I would have for each diameter measurement the total number of trees with the same diameter. Basically its multiple counters of tree diameters.

Thanks in advance,

Thomas


## Answer (score 0, by Open Foris on 2017-11-26)

Link: https://openforis.support/questions/1481/count-multiple-tree-diameters/1482

This kind of behavior is easiest achieved with through the Saiku analysis rather than with calculated variables (unless you want somehow to see this data while you are collecting the data through Collect Mobile, is that the case?? )

First of all you need to have a multiple entity (tree) with an attribute (diameter) which could be a number or a code attribute (with numbers). 

After you collect the data, import it back from Collect Mobile into Collect (Data Manager), then you can access the Saiku Analysis interface (directly from Collect, and visualize the data there (by gragging and dropping the Diameter dimension and Plot Count measure.

Does this answer your question?

> Hi, Thank you for your quick reply. As you said I do need to see the data I collect and maybe change them, correct any bad measurements. Until this point I also figured that I need to have a multiple entity (tree) with an attribute (diameter). I believe what I am hoping to achieve is a screen in the mobile with multiple counters, one for every diameter class (only even numbers eg 4cm,6cm,8cm till 80cm). Do you think it is feasible through collect mobile? I tried this in excel in the past, with macros but excel macros won't work in either android or windows mobile... Thanks again, Thomas (thomas1981)

## Answer (score 0, by Stefano (OF) on 2017-11-28)

Link: https://openforis.support/questions/1481/count-multiple-tree-diameters/1493

Hi Thomas,  
If you want to have a list of counters per diameter class, you will have to:  
 - create a code list called `diameter_class` with the values you were saying (4cm,6cm,8cm till 80cm)
 - create a calculated attribute of type Code inside the `tree` entity called `tree_diam_class`, using `diameter_class` as code list; the calculated value expressions will be:  
 a) constant value=`NA` - Apply when=idm:blank(tree_diam)  
 a) constant value=`4` - Apply when=`tree_diam <= 4`  
 b) constant value=`6` - Apply when=`tree_diam <= 6`  
 c) constant value=`8` - Apply when=`tree_diam <= 8`  
 d) constant value=`80` - Apply when=`tree_diam <= 80`  
 e) constant value=`80_plus` - Apply when=`tree_diam > 80`  
 - define a multiple entity with table layout at the same level of the tree entity and call it `tree_diam_class_counts` or whatever you want  
 - define a key code attribute inside this entity and use the `diameter_class` as code list and call it `diameter_class` 
 - define a calculated number attribute and call it `tree_sum` or similar
 - use this expression in the calculated value expression section: `count(parent()/tree[diameter_class = $this/parent()/diameter_class])`  
Basically, the expression `parent()/tree` will "access" the list of trees from your context node (the calculated attribute); when you put an expression inside square brackets "[]" you are "filtering" the target entities by some condition (in this case `diameter_class = $this/parent()/diameter_class` that means `the diameter class of the tree must be equal to the diameter class in the entity where "this" attribute is defined`).  

I hope it's clear enough, try to experiment with it a bit and let us know if you need more support from our side.  

Many thanks,  
Open Foris Team
