I suggest that you before continuing checks if you really need such nested aggr-constructs to get your wanted results and that your data-model is suitable for this kind of analysis. Even if such approach worked it could become very slow by already mid-sized datasets and in larger ones it's often deathly ...
Beside this if you want to apply different calculations for different dimensions you could query them with dimensionality() and branching then appropriate.
in this way i can count in the right way thx the dimention "codice contratto" in the aggr, but i don't need to count that dimension, i need to count how many "codice cliente" i have for every "rst codice", if i drop [Codice Contratto] of the last aggr, the count fail with a 9 as resoult, my resoult is 7, i have 7 "codice cliente" and i don't understand why this won't work:
I assume that without a quite deep diving into the dimensions of your table and the underlying datamodel it's rather difficult to give you an exact solution. Therefore the above suggestion to check your approach from the beginning. An aggr() should be nearly the last measure if really no other solutions are possible or practically.