# Drawstep engine · Values · `aggregate` > Aggregate — CR 107.1, 608.2h: greatest / least / total power, toughness, mana value or counters among filtered objects in zone (default battlefield), scoped by who. Empty sets give zero. Engine: Magic: The Gathering (`mtg`). This is one primitive of the Drawstep card vocabulary; field names and the discriminator are exact. Wiki page: https://drawstep.xyz/wiki/mtg/values#aggregate ## Where it goes A number: `{ "kind": "aggregate", … }` wherever a ValueDef is accepted (`amount`, `power`, `max`, `count` …); a plain integer is also a ValueDef. ## Fields | Field | Type | Required | Description | |---|---|---|---| | `sets` | `({ zone?: "battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"; filter?: ObjectFilter; who?: any })[]` | no | CR 400.1, 608.2h: union independently filtered/scoped object sets across zones, counting each object once; an empty union gives zero | | `target` | `TargetDef` | no | Read the property from a selection instead of a filtered zone: a declared target slot ("Choose target creature. … that creature's power" — the same `slot` as the declaring effect), `affected`, `triggering`, `triggeringOther`, `host`, `self`, `thisWay`. No prompt is ever made: an undeclared target or a resolution-time choice reads as empty (zero) | | `digSubset` | `"looked" \| "picked" \| "rest"` | no | Use the last dig's fixed subset and action-time characteristics; zone restricts actual disposition, excluding replaced moves (CR 608.2h, 609.3, 400.7) | | `op` | `"max" \| "min" \| "sum"` | yes | Aggregate over the matching objects: max, min or sum | | `property` | `"power" \| "toughness" \| "manaValue" \| "counters"` | yes | counters (CR 122.1): the number of `counter` counters on each object ("for each +1/+1 counter among other creatures you control" = op sum) | | `counter` | `string` | no | property counters: the counter kind; omitted or "any" totals every kind | | `filter` | `ObjectFilter` | no | Which objects (ObjectFilter; set fields AND together) | | `zone` | `"battlefield" \| "hand" \| "graveyard" \| "library" \| "exile" \| "stack" \| "command"` | no | A zone name (battlefield, hand, graveyard, library, exile, stack, command) | | `who` | `"you" \| "controller" \| "abilityController" \| "sourceController" \| "owner" \| "eachOpponent" \| "eachPlayer" \| "target" \| "triggeringPlayer" \| "defendingPlayer" \| "attackingPlayer" \| "activePlayer" \| "re …` | no | Which player(s) — a player selector (default `you`) | ## Minimal form ```json {"kind":"aggregate","op":"max","property":"power"} ``` The engine reads that minimal form as: “the greatest power among permanents on the battlefield”. ## Stock examples - **Iteration 35 reveal-value** — “” ```json {"kind":"aggregate","digSubset":"looked","op":"sum","property":"manaValue"} ``` - **Iteration 35 empty-value** — “” ```json {"kind":"aggregate","digSubset":"rest","op":"max","property":"power"} ``` - **Iteration 35 count-value** — “” ```json {"kind":"aggregate","digSubset":"rest","op":"max","property":"power","filter":{"types":["Creature"]},"zone":"graveyard"} ``` ## Related - [Values](https://drawstep.xyz/wiki/mtg/values.md) — the whole topic - [Filters & targets](https://drawstep.xyz/wiki/mtg/targets.md) — how `target` / `filter` select objects and players (selection algebra) - [Start here](https://drawstep.xyz/wiki/mtg/start.md) — the rules, the output contract and the index of every primitive