For enterprise edition you should use the feature to retrieve the performance data with a livestatus query.
In the linked post i showed the example of a livestatus query to fetch the raw performance data for a service.
With this json data you can do all the calculations wanted. As you mentioned the maximum value or average.