Turtle and Observer Command
sum-of-patches-with [condition] [list of commands]

Reports the total value of [list of commands] when run over the turtles that satisfy the condition. If there are no patches in which condition is true, it reports 0. Note: This command can also be executed by patches, for example within an ask-patches statement.

Examples:
sum-of-patches-with [pc = green or pc = blue] [density] returns the sum of the densities of all patches which are blue or green.

Related commands:
sum-of-patches