@gerben
Here is an example of how to do this:
If this example works for you it might be good to see wether all data, steps and custom states are good, needed or maybe things can be removed / combined, rounding differences can be prevented etc. The step after that would be to not use the data type value calculation, but to use a custom state list (type text) in which we save the start date, end date, nr of days and amount, together with the simple looper plugin this means we can do everything client side and prevent saving unnecessary data like i wrote in my initial post. The repeating group will have this custom state list as data source.
Let’s start:
1) Two data types, investment and value calculation:
2) The page and elements
A page with inputs for start date, nr of years and amount inside of a group + a repeating group to show the calculations and a button to start the calculation. Below these elements a repeating group to show the calculations linked to the investment.
3) Plugin Simple looper
To not have to use a backend workflow for looping, I used the plugin Simple looper. Install the plugin and place the Simple looper element on the page:
4) The button calculate triggers this workflow:
Step 1: Delete previous calculations related to this investment:
Step 2: Set a state calc_year to keep track of which year we are performing the calculation for and a state end_year to be able to check until which year.
Step 3: Calculate hte number of days between the selected date and the selected date + nr of years.

Step 4: Calculate the amount of amortisation /depreciation per day:

Step 5: Start the loop

5) The workflow which is looped
a) Step 1 to 6 are to create the value calculations:
- step 1 and 2 are for the first year
- step 3 and 4 for are for the years between the start year and last year
- step 5 and 6 are for the last year



b) Step 7: Add 1 to calc_year, this is used for the value calculation and also to know when to stop the loop.
c) Step 8: A check to see wether hte loop needs to be continued or stopped.

6) The result:
The result after pressing the button Calculate
*2024 is a leap year.
Good luck!