Skip to content

Commit 6f9ae36

Browse files
Minor edits
1 parent b58bdb6 commit 6f9ae36

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

source/calculations_xls.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Adding calculations in XLSForm
22

3-
Calculations can be used inside your form to derive new variables, build advanced form logic, and display results to respondents during collection.
3+
Calculations can be used inside your form to derive new variables, build advanced form logic, and display results to respondents during data collection.
44

55
Calculations are processed within the form, helping save time during data analysis. The results are stored as new columns in the final dataset and can be used throughout the form to apply [skip logic](https://support.kobotoolbox.org/skip_logic_xls.html), set [constraints](https://support.kobotoolbox.org/constraints_xls.html), or display [dynamic content](https://support.kobotoolbox.org/form_logic_xls.html#question-referencing) in question labels and notes.
66

@@ -40,7 +40,7 @@ To refer to the calculation output in the rest of your form (e.g., inside a note
4040

4141
Calculations in XLSForm can range from simple arithmetic calculations to advanced derivation of variables.
4242

43-
Arithmetic **calculations** allow you to perform basic calculations using the following **operators**:
43+
Arithmetic calculations allow you to perform basic calculations using the following **operators**:
4444

4545
| Operator | Description |
4646
|:----------|:-------------|
@@ -50,14 +50,16 @@ Arithmetic **calculations** allow you to perform basic calculations using the fo
5050
| <strong>div</strong> | Division |
5151
| <strong>mod</strong> | Modulo (calculates the remainder of a division) |
5252

53-
Calculations in XLSForm follow the **BODMAS** rule for the order of mathematical operations: **B**rackets, **O**rder of powers, **D**ivision, **M**ultiplication, **A**ddition, and **S**ubtraction. This means that calculations within brackets are performed first, followed by powers, then divisions, multiplications, and so on. Using brackets (also known as parentheses) correctly ensures that your calculations function as expected.
53+
Calculations in XLSForm follow the **BODMAS** rule for the order of mathematical operations: **B**rackets, **O**rder of powers, **D**ivision, **M**ultiplication, **A**ddition, and **S**ubtraction. This means that calculations within brackets (or parentheses) are performed first, followed by powers, then divisions, multiplications, and so on. Using brackets correctly ensures that your calculations function as expected.
5454

5555
## Advanced calculations
5656

57-
Advanced calculations in XLSForm often rely on **functions** and **regular expressions** to make calculations more efficient. [Functions](https://support.kobotoolbox.org/functions_xls.html) are predefined operations used to automatically perform complex tasks like rounding values, calculating powers, or extracting the current date. [Regular expressions](https://support.kobotoolbox.org/restrict_responses.html) (regex) are search patterns used to match specific characters within a string of text.
57+
Advanced calculations in XLSForm often rely on **functions** and **regular expressions** to make calculations more efficient.
58+
* **Functions** are predefined operations used to automatically perform complex tasks like rounding values, calculating powers, or extracting the current date.
59+
* **Regular expressions (regex)** are search patterns used to match specific characters within a string of text.
5860

5961
<p class="note">
60-
For a comprehensive list of functions available in XLSForm, see <a href="https://support.kobotoolbox.org/functions_xls.html">Using functions in XLSForm</a>.
62+
For a comprehensive list of functions available in XLSForm, see <a href="https://support.kobotoolbox.org/functions_xls.html">Using functions in XLSForm</a>. To learn more about regular expressions, see <a href="https://support.kobotoolbox.org/restrict_responses.html">Restricting text responses with regular expressions</a>.
6163
</p>
6264

6365
Examples of more advanced calculations include:
@@ -142,8 +144,5 @@ Expressions are re-evaluated when:
142144
<li>A repeat group is added or deleted</li>
143145
<li>A form is saved or finalized</li>
144146
</ul>
145-
To control when an expression is evaluated, set a <a href="https://support.kobotoolbox.org/question_options_xls.html#additional-question-options">trigger</a> to evaluate it only when a given question is answered, or the function `once()` to ensure the expression is only evaluated once (e.g., <code>once(random())</code> or <code>once(today())</code>).
147+
To control when an expression is evaluated, set a <a href="https://support.kobotoolbox.org/question_options_xls.html#additional-question-options">trigger</a> to evaluate it only when a given question is answered, or the function <code>once()</code> to ensure the expression is only evaluated once (e.g., <code>once(random())</code> or <code>once(today())</code>).
146148
</details>
147-
148-
<br>
149-

0 commit comments

Comments
 (0)