Forum Academy Marketplace Showcase Pricing Features

Create a Gainers/Losers System

I want to build a web app that will show the sales of different companys on certain date. (So, I will upload the sales).
But my doubt is about making a gainers/loosers system. (Which companies were the best, and which companies were the worse, basen on the % of increase, or decrease of each company between the two dates.

How can I make to calculate the variation between the two dates, when the user select which dates he wants to see.
I need to bubble make the calculation, because the user can select a lot of different dates combination (for example, the best between 1/1/21 - 8/1/21; between 1/1/21 - 15/1/21; between 8/1/21 - 15/1/21; imagine all the possible combinations)

Thank you so much