There is no straightforward mechanism to write aggregate user defined function, but in most cases the provided built in aggregate functions provide enough flexibility to accomplish what you want.
Please review the article Using Expressions
where you can find more info on aggregate functions and user functions.
In case you want to accomplish something more specific, please write us again and provide some visual example of your scenario.
I hope this information helps.
the Telerik team