title: Aggregate Conversion String to Int to with Mongo 3.2.9
body: <p>The issue I have is making a conversion from a string to an integer in order to create an average. I know to use the $convert in later versions, but I cannot find the correct place to use the $toInt term. I know the conversion using this keyword works on the command line on a single example, but where should I place this within the aggregate framework.</p>
  
  <pre><code>db.my_batch.aggregate([{"$unwind": "$current.Data.x"}, {"$match": {"current.Data.x.Typ": "01", "current.Data.x.Value": {"$lt": "TTTT"}}}, {"$project": {"current.Data.x.Value": 1, "uId":1}}, {"$group": {"_id": null, "ad": {"$avg": {"$toInt": "$current.Data.x.Value"}}}} ])
  </code></pre>
  
  <p>I get the following response:</p>
  
  <pre><code>2018-07-20T17:19:42.707+0200 E QUERY    [thread1] Error: command failed: {
      "ok" : 0,
      "errmsg" : "Unrecognized expression '$toInt'",
      "code" : 168,
      "codeName" : "InvalidPipelineOperator"
  } : aggregate failed :
  </code></pre>