You can refer to this article and specifically look at " Handling mismatched aggregation errors" section to understand why the error is occuring
If you follow the explanation you probably can make the required changes and fix the issue. If the issue persists then please share a sample dataset and I can try create a sample for you.