Calculations are only available if the Enable Calculations checkbox in the Assessment Settings is selected. As Brilliant Assessments calculates scores automatically most assessments do not need calculations.

**Calculations** allow you to:

- calculate answer values for reporting, for example; you may wish to calculate the return on Investment based on data collected in the assessment or
- to calculate a score based on previous input, for example, you may want to calculate a score based on a number entered into the assessment. A score calculated in this way will be added to subsection, section, assessment, and potentially a segmentation score as if it was a standard question and answer.
- both answer values and scores can use previous response answers, scores at all levels (at that point), and literals as input to the calculation.

Validations are available to inform, warn, or stop the user from entering invalid data. They use much of the structure of calculations but are documented separately.

Calculations can occur anywhere in an assessment but are hidden in the response. The results of calculations can appear in subsequent sections, however, as text in a question or instructions, using question piping; or they can be used to drive conditional questions. The system treats them as a question and an answer so all of the feedback reporting options work with calculations - either as a calculated value or a score.

Calculations use the power of Microsoft's Transact-SQL, meaning that as well as regular operators like +-*/ with or without brackets, advanced users can access the Mathematical and String functions that Transact-SQL offers for a single field. They can also use expressions like Case statements for logic. Database statements are not allowed for security reasons.

Calculations are always calculated when the responses to the section they are in is saved, either by hitting Next or Save Progress. For an answer value, you can specify whether the calculation is done before or after scoring for that page is calculated. For score values, the system will always calculate the scores both before and after calculations.

**Calculations**are denoted in the assessment builder with an = before the Calculation name.**Calculation Name**is used for identification purposes only.**Calculation Number**is used for reference and is interchangeable with a question number. For example, you can refer to a question number in a merge string in the feedback report to display the result of a calculation.**Calculation Type**specifies whether this is a calculation or a Validation.**Potential Points**should only be specified if a score is being calculated. The Potential Points will be treated in the same way as a Question's Potential Points.**Result Calculation - Merge Fields**- use the merge field drop-down lists to specify answers or scores that you wish to include in the calculation. Scores can be accessed at all summary levels. Click the Add button to insert the merge string where the cursor currently is.**Result Calculation**- Combine the merge fields with operators (+-*/), brackets and literals for your calculation. Transact-SQL Mathematical and String functions and expressions like Case statements can be used for advanced requirements. Tips:- Literals can be entered to a formula as a number for numerics, or with single quotes for character strings.
- If you have numerics that are user input, the Answer Type should be Numeric or Decimal rather than Text.
- If you have selected answers (e.g single choice) that are input to a calculation, the Answer Short Name will be used. If it is numeric it should be entered as a number with no formatting (e.g. 300000 not $300,000.)
- When scores are used in a calculation they are returned as a percentage. e.g. .6 = 60%. if you want the Likert equivalent you need to multiply it by 5 (assuming your Potential Points = 5).
- Case statements can be used to decide whether subsequent questions / subsections / sections should appear based on the current score. For example, the answer to: "Case when{RatingScore.Score}>.60 then 'true' else 'false' end" could be used as a condition for subsequent questions to be asked. (I.e. we only ask further questions if they have scored 60% or more so far. If the score is < 60% the answer will appear unselected for a condition.)
- Comments can be added between /* and */ to document the calculation
- Support will help build more complex calculations for you.

**Calculate after Scoring**- Indicates whether the scoring for the assessment, including the current page should be calculated before the Result Calculation. This is used when you need the "current score" as part of the calculation.**Result is Numeric -**if the result should all be converted into a numeric value, select this checkbox. Additional fields (Format and Number of decimals) will be displayed.**Format**for numeric fields. You can pick from General (no formatting), Thousand separated (with commas or as appropriate for the culture code of the Language of the assessment set in the assessment settings or en-US by default), Currency (again using the language), or percentage. Note that if you want to use the output as a numeric in a subsequent calculation or validation you must output it in the general format.**Number of Decimals**this field is only displayed for numeric fields. You can specify the number of Decimals will be displayed. The result of the calculation will be rounded to this number of decimals.**Score Calculation - Merge Fields**- use the merge field drop-down lists to specify answers and scores that you wish to include in the score calculation. Click the Add button to insert the merge string where the cursor currently is.**Score Calculation**- Combine the merge fields with operators (+-*/), brackets, and literals for your calculation. The result of the score calculation will be added to the assessment, section, subsection, question, and segmentation scores in the same way as an answer score. If the result is greater than the Potential Points, the Potential Points will be used. Transact-SQL Mathematical and String functions and expressions like Case statements can be used for advanced requirements. In the example shown we are calculating a score based on various levels of profit ratio.**Documentation**- unlimited documentation of calculations can be entered. They do not affect the calculation or appear anywhere but here.**Segmentations -**Calculations can be linked to segmentations in the same way as questions. Only relevant when a score calculation is used.**Conditions**- a calculation can be conditional like a question. The system will treat it as unanswered and no calculations will be done.**Report Text.**- can be used on the Feedback report when a score is calculated in the calculation.

As a system administrator, you can view the workings of Calculations from within a response, for diagnostic purposes. The Section menu (to the left of the Section name on the response header) provides access to the Calculations form.

**NOTE: Before displaying Calculations on the current page of the response, Hit Save Progress. This will cause the system to do the calculations as part of the Save Process. The same occurs when the user hits Next.**

- Calculation Name
- Section / Subsection / Question Number of the calculation
- The value calculated and the value in the format specified in the calculation form. The value is calculated to the number of decimals specified, except if the format is a percentage; in which case it is calculated to an extra 2 decimals.
- If a score is calculated the calculated score is shown here. This value will be added to the answer scores for the subsection, and any Segmentations specified on the Segmentations tab( if used). The Potential Points will be added to the same Question scores.
- The calculations are shown how they are passed to SQL for calculation.
- The system preresolves all of the merge strings - so you can see the current values.
- SQL has a quirk that if it is only passed whole numbers it will always return a whole number. For that reason, we multiply numbers by 1.00 to give the numbers decimal places.
- If there is an error in the calculation an error message will be shown. That error is from SQL and is usually quite cryptic. Most errors are caused by unmatched brackets or missing operators. Support can help you with these if you can not find them.

## Comments

0 comments

Please sign in to leave a comment.