A custom print template can do simple calculations with a form's answers when it prints, for example adding two Number field answers or working out hours worked from a start and finish time. You write the calculation into your template, using the placeholders from the form's Custom Printing tab on the Assignar dashboard. You need the Forms permission. This is an advanced task: set up a basic custom print first.
Add, subtract, multiply or divide answers in a custom print
To calculate with two Number field answers in a custom print, put both placeholders inside one pair of curly brackets with the operator between them:
Add:
{$id2 + $id3}Subtract:
{$id2 - $id3}Multiply:
{$id2 * $id3}Divide:
{$id2 / $id3}
Use the placeholders from your own form's Custom Printing tab. Inside a repeating question group, use the _row.data placeholders, for example {$_row.data.id5 * $_row.data.id6}.
Round a number in a custom print
To round a number in a custom print, add a modifier after the placeholder:
{$id2|round:2}rounds to 2 decimal places.{$id2|ceil}rounds up to a whole number.{$id2|floor}rounds down to a whole number.
Work out hours from a start and finish time in a custom print
Time answers are printed as text such as 18:30, so subtracting them directly ignores the minutes (18:30 - 06:00 gives 12, not 12.5). To get hours worked, convert both times to minutes first. For a repeating group where question 5 is Start, question 6 is Finish and question 7 is the break in minutes:
{((($_row.data.id6|substr:0:2)*60)+($_row.data.id6|substr:3:5)-(($_row.data.id5|substr:0:2)*60)-($_row.data.id5|substr:3:5)-$_row.data.id7)/60}For a 6:00 am start, 6:30 pm finish and 30-minute break this prints 12. Replace the question numbers with your own.
Use the totals in a Site Diary custom print
Site Diary custom prints don't need calculations for crew totals. The Site Diary print variables include Totals placeholders such as {$work_total}, {$break_total} and {$daily_total}. See How do I set up a custom print for a Site Diary on the dashboard?.
Why does my calculation print the wrong number or the formula itself?
If a calculation in a custom print doesn't work:
The question isn't a Number field. Text answers can't be calculated.
A bracket or
$is missing. Count the brackets; every placeholder inside the calculation keeps its$.The placeholder numbers are from another form. Copy them from this form's Custom Printing tab.
