loanTotalCost() Function

Total amount repaid over the full loan term — show the true cost of financing in mortgage and credit calculators.

formulas functions loan

loanTotalCost()

Calculate the total amount repaid over the full loan term (all installments plus financed fees) — essential for “how much will I pay in total?” lines on loan calculators.


Syntax

Every formula in Calcopolis must start with = in the Value field:

= loanTotalCost(amount, interestRate, months, commission, installments)
Part Rule
Function name loanTotalCost — camelCase
interestRate Annual rate as decimal (0.05 = 5%)
Optional commission (decimal), installments ("EQUAL" or "DECREASING")
Return value Sum of all payments over the term

Valid examples

= loanTotalCost(loan_amount, interest_rate/100, term_months)
= roundTo(loanTotalCost(loan_amount, interest_rate/100, term_months, 0.01), 2)

Invalid / unsupported

Don't write Why
Using percent rate directly Use interest_rate/100 when the form collects percent

Parameters

Argument Description
amount Loan principal.
interestRate Annual interest as decimal.
months Loan term in months.
commission Up-front fee as decimal of principal. Default 0.
installments "EQUAL" or "DECREASING". Default "EQUAL".

When to use loanTotalCost()

Use alongside monthly payment for full-picture finance UX:

Situation What loanTotalCost() does
Total repayment Principal + interest + fees across the term
Compare offers Same principal, different rates or commissions
DECREASING loans Sums each decreasing installment

Subtract principal (and commission) manually, or use [loanTotalInterest()](/docs/reference/formulas/loan-total-interest-function/) for interest-only totals.


Practical examples (ecommerce & leads)

1. Mortgage summary block

Variable Formula
monthly_payment = roundTo(loanInstallmentAmount(loan_amount, interest_rate/100, term_months), 2)
total_repaid = roundTo(loanTotalCost(loan_amount, interest_rate/100, term_months), 2)

Show both on Result widgets.

2. Compare with and without origination fee

Variable Formula
total_with_fee = loanTotalCost(loan_amount, interest_rate/100, term_months, 0.02)
total_no_fee = loanTotalCost(loan_amount, interest_rate/100, term_months, 0)

Where to use it

Location Supported
Result widget Value Yes — = ... formulas
Standalone variable (Variables tab) Yes
Number / other input default Value Yes, if formula-driven
Visibility formula Yes
Custom Text / Table cells No — use {{ }} templates there, not = functions

After editing, run Calculate (or enable Run calculation on load in project Options) to refresh results.


← Back to Reference

Still have unanswered questions?

We are here to help. Reach out and our team will get back to you.

Contact support