The general rule is that you can’t mix aggregated values and non-aggregated values in the same calculated field. There’s a section in this article that goes over mismatched aggregation errors.
This second article also covers the topic of mismatched aggregation.
If you can describe what you’re trying to calculate, I can help you come up with the correct calculated field.