Calculated results: figures worked out instantly in gifts and quizzes
Add figures to a gift or scorecard quiz that are worked out instantly from what each person answers (stamp duty, a deposit, a repayment), with formulas and rate tables, no AI and no credits. Includes calculator-only gifts.
Calculated results let a gift or a quiz work out figures for each person the moment they answer: stamp duty, a deposit, a loan-to-value percentage, a repayment. You write each figure once, as a name and a formula over the questions you ask. The figures appear instantly, cost no credits and use no AI, so they are the same every time for the same answers.
You set them up in a gift at https://app.trustpager.com/operations/gifts and in a scorecard quiz at https://app.trustpager.com/operations/quizzes. Open the gift or quiz and choose Calculated results in the list on the left. (In a gift it sits in the What it makes group. A test with right and wrong answers has no number questions, so use a scorecard.)
What people see
Under the heading Your figures each figure shows with its name, for example "Stamp duty: $31,490". Money shows in your workspace's currency, following your workspace's country (an Australian workspace shows dollars the Australian way). A figure that cannot be worked out shows Not available instead of a wrong number. That happens when a formula divides by zero, when a question they needed was skipped, when no rate table row fits their answer (for example a state you did not list), or when the result would be too large.
The figures are worked out again by TrustPager from their answers every time, so nobody can change a figure by editing the page.
Set one up
- Ask for the numbers. Add a question and set its Answer type to A number. Choose Shown as: A plain number, An amount of money ($) or A percentage (%). Optionally set Lowest, Highest and Step (how far one tap of the arrow moves it). An answer outside the lowest and highest is refused on their page, with the range shown. A money question shows your currency symbol beside the box. A percentage is typed as 6 for 6%, so write rate / 100 in a formula.
- Check each question's key. Every question has a Key for calculated results, the short name a formula uses, like
price. Leave it empty and TrustPager makes one from the question. A key is lower case letters, digits and underscores, starts with a letter and is up to 40 characters. In the Calculated results section, Your answers, by key lists every key: click one to copy it. - Add a result. Choose Add a result. Fill in Name people see, the Formula, Shown as (Number, Money ($) or Percent (%)) and a Key, which lets a later formula use this result.
- Add rate tables if you need them (see below).
- Try it. The preview on the right is headed Try it: type some answers. Type answers and the figures appear underneath, worked out the way a person's page works them out. Nothing is saved and it costs nothing.
- Go live. A gift can go live with only calculated results. See the end of this article.
It all saves by itself once it is valid. If something is wrong, an amber Not saved yet note says what to fix in plain words, and the last good version stays in use, so nobody ever sees a half-written formula.
Writing a formula
A formula is written like one in a spreadsheet, using the keys of your questions and results.
- Sums: + (add), - (take away), * (times), / (divide by) and ^ (to the power of), with brackets to group.
- Comparisons: =, !=, <, <=, > and >=, joined with
and,orandnot. - Words go in quotes, like
state = "NSW". Capital letters and extra spaces are forgiven.
Functions you can use:
if(condition, value if true, value if not)min(a, b, ...)andmax(a, b, ...): the smallest and the largest.round(number, decimal places)(rounds half up),floor(number)(rounds down),ceil(number)(rounds up) andabs(number)(drops the minus sign).has(question, "option"): true when that option was ticked in a several-answers question.brackets(rate table, amount): a tiered amount such as stamp duty.lookup(table, key, value if missing): the value for a key such as a state. The last part is optional.
How each kind of answer reaches a formula:
- A number and Scale of 1 to 10: the number.
- One answer: the words of the option they chose, for example
state = "NSW". - One answer with the options Yes and No: true or false, so
if(first_home, 0, duty)works directly. - Several answers: use
has(extras, "Pest inspection"). - Short text, Long text and Their website: the words they typed.
- Not answered: nothing, so a figure that needs it shows Not available.
Examples:
- Money left to find:
price - deposit, shown as Money ($). - Loan as a percentage of the price:
loan / price * 100, shown as Percent (%). - A fee that is never below $200:
max(200, price * 0.01). - No duty for a first home:
if(first_home, 0, duty).
A formula can use the key of another result, so you can build a figure in steps. A formula that cannot make sense (for example adding words to a number) is not saved, and the note tells you which result to fix.
Rate tables
A rate table holds rates a formula looks up. In the Calculated results section, below Results, choose Add tiered amounts or Add a value per answer. A window opens, with a Table name (lower case letters, digits and underscores, like nsw_duty), which is how formulas refer to it. Choose Done when finished, or Remove this table.
Tiered amounts (brackets)
For rates that change as the amount grows, such as stamp duty. The window is titled Rate table: tiered amounts, with one row for each tier:
- From and Up to: where the tier starts and ends. Each tier starts where the one before ends, and the last tier says "and above", so every amount is covered.
- Already owed at the start: the amount already owed when the tier begins.
- Rate for each $1 above: typed as a percentage, for example 2 for 2%.
For an amount inside a tier, the result is the amount already owed at the start of the tier, plus the rate for each $1 above where the tier starts. Choose Add a tier to add one.
Example (made-up rates, to show the idea only): tier 1 from 0 up to 100,000, owed 0, rate 1%. Tier 2 from 100,000 up to 500,000, already owed 1,000, rate 2%. Tier 3 from 500,000 and above, already owed 9,000, rate 3%. A price of 600,000 gives 9,000 plus 3% of the 100,000 above 500,000, which is 12,000. The formula is brackets(my_duty, price). Use the real rates for your state or product.
A value for each answer (lookup)
For a value that depends on a choice, such as a rate for each state. The window is titled Rate table: a value for each answer, with two columns: When the answer is and The value is. Choose Add a row for each choice. Each key can appear once, and capital letters and spaces are ignored when matching.
The value is either a number, such as a surcharge rate (use it as lookup(surcharge_rate, state) * price), or the name of a tiered table. That lets one figure use a different tier table for each state:
brackets(lookup(duty_by_state, state), price)
Give lookup a third value to use when the answer is not listed, for example lookup(surcharge_rate, state, 0). Without it, an unlisted answer shows Not available.
Limits
- Up to 50 results and 30 rate tables in one gift or quiz.
- Up to 200 rows in a table.
- A formula can be up to 2,000 characters.
- A key or table name can be up to 40 characters, and a name or label up to 100.
- A word typed inside a formula can be up to 200 characters.
The words and, or, not, true and false, and the function names above, cannot be used as keys or table names.
A calculator-only gift
A gift does not have to make a PDF, a picture or a video. If you switch nothing on under What it makes and add calculated results, it is a calculator-only gift. The builder says it makes "no files, only calculated results", and the person's figures appear the moment they answer, at no cost. Nothing to wait for, and it can be set to Live on its own. If a gift does make something as well, the figures appear first and the rest follows when it is ready.
Try a gift with Try it yourself in the gift builder. It makes a sample for a sample business and shows the figures at the top. The parts that make things are charged as a real gift, the figures are free.
Where people use them
- On a Lead Magnet page, through a Made for you block (gift) or a Quiz block (quiz): https://trustpager.com/help-center/lead-magnets-private-pages.
- Inside client portals, under Free tools (gifts only): https://trustpager.com/help-center/how-to-set-up-a-client-portal.
- On your own website, as a calculator or scorecard: https://trustpager.com/help-center/website-tools.
More on each kind: https://trustpager.com/help-center/gifts-made-for-each-person and https://trustpager.com/help-center/quizzes.
Using your assistant instead
Everything here is also available to Evie, or to your own Claude connected through the TrustPager connector. It can set a gift's or quiz's calculated results (update_gift and update_quiz), and try answers without saving anything (calculate_gift and calculate_quiz). Gifts need the gifts permissions and quizzes the quizzes permissions. For exact tool and field names see https://docs.trustpager.com/reference#gifts and https://docs.trustpager.com/reference#quizzes.
If something looks wrong
- I see "Not saved yet": read the note. It says which result or table to fix, for example a table that has no rows, or a formula that uses a key that does not exist. Nothing changes for your readers until it is fixed.
- A figure says Not available: the answers given have no figure. Check for a skipped question, a division by zero, or an answer that has no row in your rate table (add the row, or give lookup a value to use when missing).
- The key I typed is refused: it must be lower case letters, digits and underscores, start with a letter, and not be one of the reserved words.
- A percentage looks 100 times too big or small: a percentage question is typed as 6 for 6%, so divide by 100 inside a formula. A result shown as Percent (%) is the number with a % sign after it, so 80 shows as 80%.
- The gift will not go live: it needs something to make, or at least one calculated result.
Build it once in the Calculators library
Instead of writing figures inside each gift or quiz, you can build a calculator once in the library at https://app.trustpager.com/operations/calculators and link it. Publishing the calculator updates every gift, quiz and website calculator linked to it, and runs can be saved onto the contact's opportunity. The library has its own article: https://trustpager.com/help-center/calculators.