Hi, I have a problem I am finding difficult to solve. Hopefully, someone in the community has encountered this before and can provide some clever solutions to this.
First of all, the modules I am showing here are just to explain the problem I am trying to solve. The actual modules are on a very large data set so I need to keep the line item count low.
I need to spread an amount (project cost) over time, based on a spreading rule and starting from a point in time, based on the project finish month.
#1 First of, I have this spreading table (below) which has just one line item to hold the percentage used to spread the project cost amount. On the columns, I have one list (Project time settings), where the "0" is the month of the project finish and "-1" is one month prior to the project finish month, "1" is one month after the project finish month, and so on.
In the rows I have one list (project time spread rules) which determines what pattern the amount spreading should follow and how much should be spread at each point in time.


#2 I also have the data module which contains one list (Accounts) and line items: project cost, Time spread rule (same list as list dimension in #1), and project finish month.

#3 Finally, I have my calculation module which is essentially the same as the data module in #2, but with time (month) as a dimension as well. The rent account has 1 000 000 USD that should be spread with starting point (Jun 22), based on the spreading rule "CN". If we look at the spreading table in #1 that means in month 0 (Jun22), 15% of 1 000 000 should be allocated, month -1 35%, month - 2 35% and month +2 15%.
If you look at the picture below you can see the amount spread in the Project Cost Spreading. The thing that is not working right now and that I need help with is the logic for the line item "Time Spread Number". It should count the period forward and backward from the month of the project finish date. So in this example the project ended on Jun 22 which then becomes month 0, May 22 becomes -1 Jul 22 then becomes 1, and so it continues in both directions.


Kind regards