Database
[{"sensorId":101,"sensorType":"s101","BuildingId":"b101","CalcItems":[{"Ts":"2019-07-01T18:30:00.000+00:00","Value":2},{"Ts":"2019-07-01T15:30:00.000+00:00","Value":4},{"Ts":"2019-07-02T18:30:00.000+00:00","Value":2},{"Ts":"2019-08-01T18:30:00.000+00:00","Value":2}]},{"sensorId":102,"sensorType":"s102","BuildingId":"b102","CalcItems":[{"Ts":"2019-07-01T18:30:00.000+00:00","Value":4}]}]
Query
db.collection.aggregate([{"$unwind":"$CalcItems"},{$group:{_id:{"sensorType":"$sensorType","BuildingId":"$BuildingId","Ts":{"$substr":["$CalcItems.Ts",0,10]}},"total":{"$sum":"$CalcItems.Value"}}},{$group:{_id:{"sensorType":"$_id.sensorType","BuildingId":"$_id.BuildingId"},"CalcItems":{"$push":{"Ts":"$_id.Ts","Value":"$total"}}}},{"$project":{"_id":0,"sensorType":"$_id.sensorType","BuildingVal":"$_id.BuildingId","CalcItems":1}}])