Calculate coast energy - day/week/month

I am getting real-time information about energy consumption. Like:
-Grind Frequency
-Active Power
-Reactive Power
-Power Factor
-Active Energy
-Reactive Energy

Now i would like to calculate coast energy by Day/this week,last week/this month/last,month
Could someone please advise me how to do it ? Calculate in grafana or write some rule in OH ?
some example?

Have you read this post?
Thought maybe it could help get you started or give some ideas. Charting looks to be the easy part, calculation not so much.