Select to view content in your preferred language

Group By Expression

742
6
08-14-2023 09:46 AM
Cheetah24
Emerging Contributor

Hi

 

I'm trying to use a table and by species display totals for Alive, Injured and Dead animals. I am trying to use an expression and return a featureset that displays the totals for each of the mentioned but can't get it right. The field i have as the Data populated as 'AOR', "DOR' and 'IOR'. How can i sum these by value and display them in the correct column? So for each species I need to know how many were alive, dead and injured for the entire dataset.

Thanks

0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor

I use the GroupBy expression like this to get the counts of each attribute in a field (Habitat).

var totalHabitat = GroupBy(fs, 'HABITAT', { name: 'HabTypes', expression: '1', statistic: 'COUNT' });

 

This gives me this table by setting the Category field to "Habitat" and getting the sum of the "HabTypes" field.

table1.png

0 Kudos
Cheetah24
Emerging Contributor

Thanks for the response.

I had tried something similar but it just counts the number of rows. It doesn't seem to care what value is in my "Alive" field.

0 Kudos
KenBuja
MVP Esteemed Contributor

How is your data formatted? Do you have individual fields for each category showing how many animals are in that category? Your initial description sounded like there was one field showing if it's alive, injured, or dead.

0 Kudos
Cheetah24
Emerging Contributor

So it would be something like this:

 
BullfrogAOR
MinkDOR
BullfrogDOR
CrowDOR

 

And what I would like to see in a table is

SpeciesAliveDeadInjured
Bullfrog110
Mink010
Crow010

 

0 Kudos
Cheetah24
Emerging Contributor

Finally got it working. thanks for your help

0 Kudos
KenBuja
MVP Esteemed Contributor

Great! What was your solution?

0 Kudos