Counting unique values

1501
4
02-08-2019 01:51 PM
Highlighted
New Contributor

My survey contains a list of 125 plant species.  The user selects plant species along transects and counts the # of of each.  In my 'count species' function, every time a species is counted, it registers as 1.  If the same species is counted multiple times, it is counted multiple times, inflating my final species count.  I need to only count the unique species selected from the list to get an accurate result.  Is there a way to do this?

Reply
0 Kudos
4 Replies
Highlighted
MVP Esteemed Contributor

what does your count species function look like?

Reply
0 Kudos
Highlighted
New Contributor

I have two groups of plants that use the same plant list.  One we call indicators and the other is called non-indicators.  The count function is pasted below.  

type                              name                        label

select_one list_11indicatorsSelect Species

calculation

count(${indicators})

The syntax is the same for non-indicators.

Any suggestions are appreciated.

Jimmy

Reply
0 Kudos
Highlighted
Frequent Contributor II

Add a column to your choice list that has say a 1 or 0 in it - 1 if you want to count it.  Have field 2 do a pulldata on the species name that grabs the 1 or 0.  Then do a count or sum on that field with the number in it.

Opps missed the unique part.  You need another field that does a concat to create a list of all values in the repeat.  Then add a If on the count that has a contains on this field.  So If FieldA contains FiledB then 1 else 0.

This a good post about making a field list.   https://community.esri.com/thread/189428-summerize-data-within-a-repeat-survey123

Reply
0 Kudos
Highlighted
New Contributor

You can just have a field for joinning all the selected species (e.g. selection =  join(',', ${species})

And then another field where you:

  • Check if a species is present in field selection
  • Assign "1" if it is
  • Perform a sum

(e.g. if(contains(${selection}, 'Specie1'),1,0) + if(contains(${selection}, 'Specie2'),1,0) +...

Reply
0 Kudos