Skip to content

$avg

Calculates the arithmetic mean of the supplied numeric values.

Syntax

{ "$avg": <arrayExpression> }

Example

Input

{ "scores": [90, 85, 95] }

Stage

{ "$project": { "averageScore": { "$avg": "$scores" } } }

Output

{ "averageScore": 90 }