Calculations with ELK

i am using ELK in order to analyse retails transactions and in my project i have data that contains transactions made between 2016 and 2017, product , revenue by each product ... i need to calculate the total revenue for all the products which had been sold for each year then substruct the total revenue of 2017 by the one of 2016 the divide it by the last one.
I did created a scripted field with kibana using the expression language to create a field that contains the revenue for each product but right now i am really confused betwenn using painless or to use aggregations to implement this formula and calculate the the revenue year to day (= total revenue of 2017 -total revenue of 2016 /total revenue of 2016) ???,

if am going to use painless does that mean that the result will be stored in each document of the index ?? and if i use aggregation with script ,how could i use the result in a visualization ???

Please don't post the same thing more than once - Scripted metrics