Problem with query Mongo

Hi all,

I am trying to make a sum of two count results, that is my query:

[
  { "$facet": {
    "Total": [
      { "$match" : { "status": { "$eq": "approved" }}},
      { "$count": "Total" }
    ],
    "Approved": [
      { "$match" : {"status": { "$eq": "pending" }}},
      { "$count": "Approved" }
    ]
  }},
  {"$addFields":{"overall":{ "$sum": ["$Total", "$Approved"]}}},
  
  { "$project": {
    "Total": { "$arrayElemAt": ["$Total.Total", 0] },
    "Approved": { "$arrayElemAt": ["$Approved.Approved", 0] },
    "overall":"$overall"
  }}
]

and I get these answer:
123123
There are no error message but overall as sum of 2 count equals 0
Can anyone help me with this problem?

Hi @hoangnguyen
You will likely find much better help in the MongoDB community, since your question isn’t related to Metabase:
https://www.mongodb.com/community-support-resources