That is a good question and the kind of information we need to feed into our platform roadmap.
Firstly, your question implies that you need to limit the generated exported lines to those related to a specific case (that has just finished its process). If so, that can be awkward to do in itself. In 10.4 (releasing any day now), we have added a new rule action called ‘Export associated records’ which allows you to do this more easily.
Regarding having a custom heading containing dynamics aggregates, there is currently no easy way to do this.
As a workaround, you might be able to create a dummy, transient record that (i) has the aggregated data populated by a (Code Studio) Event Action and (ii) will appear at the top of the export file according to the Export File Type ordering rules and (iii) is deleted after the export is finished. (You’d need to consider carefully the impact of having those transient records).
We plan to allow coders to write to files (eg CSV files) directly from within Code Studio. With this functionality you’d have to write the whole file but at least you’d have complete control. I will also add an item to our wishlist though that would address your specific problem - allowing you to use Code Studio just to define what the header line should look like.
Final thought - If your “finance system” is third party software, make sure you have checked it doesn’t offer alternatives to the CSV file. Perhaps it has a REST API for example that you could use other features of Liberty Create to integrate with.
Feel free to ask more questions on this.