As Treseco told, you cant have coalc dim in aggr. But in the case from your example expression:
should give expected result. You may need maybe one more if to check cases that there is no d2 for some d1.
Maybe in you real case you may use similiar....