- Use Case: Use Duration Values in Calculations
Calculations are used to add items like invoice totals, inspection scores and other calculated values in mobile forms. Use calculations to total work hours, find average inspection scores, and calculate costs within forms.
Calculations work with numeric answers only. Use String Concatenation to string together alphanumeric characters.
Note: There are questions that are specifically suited for calculating date/time values.
When building a form, Integer, Decimal and Currency Calculations are found under Add > Number > Integer (1) / Decimal (1.111) / Currency ($1.11) > Calculation.
It is important to add the correct calculation control for the type of number being calculated, as the question will display the answer in that format (ex. currency will display as a monetary value). However, every calculation question type can use any number question.
Use common calculation functions to build the expression the question should perform.
Build calculations under the Calculation Properties tab using the onscreen keypad, or the computer keyboard. To use answers from questions in the form, hit the Qu button on the calculator to select from all preceding number-type questions in the form. Calculations work with numeric answers only. If a question cannot be used in a calculation, or if the question comes after calculation in the form, it will not be displayed in the Qu dropdown.
Note: When building calculations with duration data, it is necessary to divide the total by the following:
- Per Hour: Divide time by 60, twice ([time value] / 60 /60), such as when calculating cost per hour.
- Per Minute: Divide time by 60, once ([time value] / 60), such as when calculating distance per minute.
Set a default value for each of the questions used in the calculation. This is especially important where forms have have skip logic, or input questions are not required. If a referenced answer is empty and there is no default value, the user will receive an error message and be unable to submit the form.
Use the "::" button at the bottom right of the calculator to insert the symbol for the default value, and follow it with a 0 or 1. This should appear at the end of every question referenced in the calculation.
- For all questions except those involving division, set a default value of 0
- For a question that will be involved in a division calculation, set a default of 1 (a default of 0 will produce an error message)
In this example, [Unit_Price], [Unit_Discount], and [Units_Ordered] have all been given a default value of ::0.
To calculate the total cost of hours worked, use a currency calculation combined with a duration question. This is useful for invoices and payroll.
- Add a duration question (or questions) to collect hours, a currency number question to collect the rate of pay, and a currency calculation question following them.
- Under Currency Value Properties in the Hourly Rate and Calculation questions, set the Default Currency. It is USD by default. Optionally set minimum and maximum values.
- Under Calculation Properties, multiply the duration question by the pay rate question.
- Note: When performing calculations with duration questions, you must divide the total (/60/60) to calculate a cost per hour.
For Example: The above calculation would be [(Hourly Rate) * (Hours_Worked]) /60 /60]