I have gone through the attached sample spreadsheet you have posted.
I have mostly understood your requirement, it's explained in a very crisp manner. However, I have a few questions to make a few more points clear.
Please have a look at the questions (attached with the PM), and if you please answer them, we could proceed with the work.