<< Click to Display Table of Contents >> Dynamic Calculator Script |
![]() ![]() ![]() |
he dynamic calculator means that the value of each grid is calculated dynamically, and it can also be called a grid calculation. The main solution is to dynamically calculate the values in a specific direction in the table. There are two elements, namely the calculation direction and the calculation method (or function).
The direction of calculation is related to the structure of the table. If you want to do ring calculations for product quarterly increments, you need to group the product fields and quarter fields along the quarterly field. We call a group a partition. What direction is called based on the Addressing.
The calculation function includes the difference, the percent from, the percent difference, the percent of total, and the running total and the moving calculation. Each calculation function has some special properties and parameters.
Users can also customize the calculation function and calculation direction according to their needs. For a custom calculation function, you can also use the properties of the second calculation, that is, the current dynamic calculation can use the results of other dynamic calculations to do a second calculation.
The purpose of this chapter is to introduce how to customize calculation functions through scripts.
❖Open script dialog
Choose adding dynamic calculator in the drop-down list of measure data segment of table, Pivot and chart, as shown in the image below.
In the Open Dynamic Calculator dialog, select Custom as shown in the following figure.
Then open the script input dialog, as shown below. The user can invoke the fifteen dynamic calculation functions provided under the Dynamic Calculation folder. For a detailed description of dynamic calculation functions, see dynamic calculation script function.
[Name] is the name of the data segment after adding a dynamic calculator script.
When the user uses the script for dynamic calculation, click the OK button to enter the dynamic calculation dialog again. In this dialog , the user can set the direction of dynamic calculation by calculating based on the options. When the user needs to edit the expression again, click the edit button, then the expression can be edited again.
[Secondary] That is, other scripts dynamically calculate the data segment name in the current expression. If there is already a script dynamic calculation data segment with the name movingAVG, when the user uses the movingAVG data segment again in the current expression, it belongs to the second script dynamic calculation, such as the expression movingMin(col['movingAVG'], 2,2, true, true); The user needs to check the secondary calculation option.
❖Application examples
There is a table as shown below.
When the user needs to count the total profits of each type of market, the runningSum() function can be called. The script statement is runningSum(Sum(col['PROFIT']), col['TYPE']); .
The result of the calculation is shown in the figure below.