# Sum of var1 for only goat, cow and sheep

Hello,
I need help with the syntax. I have a roster with var1 of number animals. the Roster has animals by catelogy like large animals like goat, cow, sheep and small animals like rabbits, Guinea pigs, Gerbils,etc…
but my challenge is to get the sum of large animals of var1 without adding small animals in var1.

Can you explain if you have a list where you register the animals and then for each animal you have a selection question to find out if the animal is large or small?

Yes , its a fixed roster with those animals.

Well, you can have a syntax like this:

`AnimalsRoster.Count(x => x.size == 1)`

Assuming that “size” is the name of the variable in which you ask for the size of the animal and that 1 represents the large size.

Based on what @francisk has written there is no separate question on the size of the animal, but a quantity in the fixed roster (typically “number of heads” for that animal type).

The computer itself doesn’t know which animals are supposed to be treated as ‘small’ and which ones as ‘large’.

One can easily tell this by assigning proper animal codes, such as 0…99 for large animals, and 100…200 for small animals.

Then one would do

``````S=ANIMALS.Where(a=>a.@rowcode<100).Sum(a=>a.NumHeads)
``````

Other possible solutions involve using InList() function to tell which animals are large and small, or lookup tables if the number of animals is large.

Thank you sergiy and Kevin.