Overview
This document mainly introduces how to use formulas in Word reports.
Formula Use Requirements:
1. You do not need to nest formats when inserting formulas in Word. For example, the syntax for inserting a cell is {{=M3}}. If you want to sum this cell, the correct syntax is {{=SUM(M3)}}, rather than {{=SUM({{=M3}})}}.
2. You cannot reference hierarchical coordinates when inserting formulas in Word.
3. You need to use the nested IF function (if(condition,result1,(if(condition,result2,result3)))) in actual development scenarios with multiple conditions to be judged, rather than just two conditions to be judged in the if-else statement.
For example, three conditions (rising, falling, and fair) need to be judged during indicator analysis.
In this case, the formula is {{=if(N23<0,"falling "+format(N23*-1," #0.0%"),if(N23>0,"rising "+ format(N23," #0.0%"),"fair"))}}.
Requirements on Repeated Dynamic Text Widgets:
1. Parameters in widgets cannot be repeated. To repeat parameters, you need to add an equal sign (=). For example, if the custom parameter is {{=$a}}, you need to enter {{==$a}} to reference it in widgets.
2. The text to be repeated needs to be in a separate line, otherwise line break problems may occur.
3. You are advised to use indirect references in parameters of formulas in the text repeat widgets, rather than use cells directly (as they may cause semantic problems).
Referencing Cells
You can display relevant content in a Word report by referencing cells of the current template through formulas, as shown in the following table.
Cells Extended or Not | Formula | Formula Result |
---|---|---|
No | {{=A2}} | Displays the content of the current cell. For example, if the content in cell A2 is 1, 2, and 3, the formula result is 1, 2, and 3.
|
Yes | {{=A2}} | Displays the last result in all the extended content of cell A2. For example, if the content in cell A2 is 1 to 10, the formula result is 10.
|
Yes | {{=A2!}} | Displays all the extended content of cell A2, adds all the extended content to a set, and converts the content into strings. For example, if the content in cell A2 is 1 to 10, the formula result is 1 to 10.
|
You cannot reference cells from other templates through formulas of Word, but you can reference cells from other sheets of the current template, as shown in the following table.
Cells Extended or Not | Formula | Formula Result |
---|---|---|
No | {{=1:A2}} | Displays the content of cell A2 in sheet2. 1: represents the index coordinate of the sheet. A2: represents the cell in the corresponding sheet. For example, if the content in cell A2 is 1, 2, and 3, the formula result is 1, 2, and 3. |
Yes | {{=1:A2}} | Displays the last result of all extended content of cell A2 in sheet2. 1: represents the index coordinate of the sheet. A2: represents the cell in the corresponding sheet. For example, if the content in cell A2 is 1 to 100, the formula result is 100. |
Yes | {{=1:A2!}} | Displays all the extended content of cell A2, adds all the extended content to a set, and converts the content into strings. 1: represents the index coordinate of the sheet. A2: represents the cell in the corresponding sheet. For example, if the content in cell A2 is 1 to 100, the formula result is 1 to 100. |
Referencing Formulas in Dynamic Text Repeat Widgets
You can specify the repeat quantity in the dynamic text repeat widgets and reference the content to be repeated through formulas. The following table shows cases in which the cell content and dynamic text repeat widgets are used together.
Repetition Quantity | Formula Used in Repeated Content | Formula Result |
---|---|---|
3 | {{=SUM(1,3)}} | Displays only one result. By default, only the first widget can obtain the result value and other widgets obtains empty values.
|
3 | {{==SUM(1,3)}} | Displays the same result for all text widgets.
|
3 | {{=RANGE(1,3)}} | Displays extended results with values taken from each text widget separately. For example, if there are three text widgets, the formula result is 1, 2, and 3.
|
3 | {{=A2!}} | Displays extended cell result values for each text widget separately. A2: represents the extended cell. |