While all variables in a calculate field need to be aggregated, often *simple data* is not affected if using min() and max(). I would try that and let us know how it goes. I also may have missed the point of this post entirely but maybe Bora Beran can help.
SCRIPT_ calculations are table calculations which operate on data in the visualization, since data in the visualization is generally aggregated calculation needs to know aggregation to use. If you would like to use row level data, you can achieve this by unchecking the Aggregate Measures option in Analysis menu. This way you will be working with disaggregate data even if your formula has SUM(field name) etc.