Pull date entry from LAST repeat


I have a form which calculates loan payments over time.
Users apply for a loan are asked to repay within 6 months and need to pay a fee per month.
Something like this:
Someone applies for 40000
5% of that is 2000
Over 6 months that is a fee of 2000 a month.
If they pay it back after 3 months, they would pay 40000 + 6000
If they repay after 8 months, would that be 40000 + 16000 + Penalty

In order to calculate this I currently have set up a repeat group to capture each payment.
Date of payment and payment made.
The sum of the payment is then calculated outside of the repeat.
In order to calculate the correct fee I would need to know the final payment made and see if this is within 6 months of the application.
To keep the form as simple as possible for the user I would ideally want to pull the date from the LAST payment made and calculate the fee from that. Is that possible or I am overthinking this.


Welcome to the community, @finicella! Could you also let the community know why you chose the calculation to be inside the repeat group? Why did you not opt to keep the calculation outside the repeat group?

We want to make this from as easy as possible for those inputting the data. The whole loan process is managed within the one form, from application, payment to closure. The idea of the repeat is to allow individual payments over time to be captured.

And to add, this is a great community and I have learned a lot from it.

Looks like I have found a solution. I calculate months between loan date & payment date and then use the max() function to pull the highest month from the repeats and use that to calculate the fee.