Type conversation from string to number

Hello @edith_t, Welcome back the the MongoDB community forum,

You can use $toInt or $toDecimal operator to convert type something like this,

db.Compras.aggregate([
  {
    $group: {
      _id: { Agente: "$comercio.agente.idAgente" },
      total: { $sum: { $toDecimal: "$compra.montoTotal" } }
    }
  }
]);
2 Likes