Rounding and average
In a TGKML script it is possible to:
- round the value of an account to a given number of significant digits;
- calculate the average of a given expression.
Rounding¶
The function to use to round the value of an account to a given number of significant digits (number of decimals) is
Round(n)
where n is an integer that specifies the number of decimal figures to take into account.
Thus, if we write
… := [C00000](Round(2));
the value of the C00000 account is read rounded at two decimal figures.
On the other hand, if we write
[LO].[X00000](Round(2)) := …;
the value of the output account X00000 is rounded to two decimal digits.
When using the Round(n) function in output, the rounding applies to the final result that includes the negative amounts with not calculated origin. For example, if we round to zero decimal digits the result of a calculation that gives 1 and the database already includes a data with amount 0.1 and other origin, we will get a record with amount 1 (1 - 0.1 = 0.9 rounded to 1) with calculation origin. So the total on the database will be 1.1.
Whereas, when using the Round(n)function in input, the rounding is applied only to the data reading and, in the previous example, we would get a record with amount 0.9 (Round(1,0) - 0.1 = 1 - 0.1) with calculation origin. The total on the database will be 1.
Average¶
Tagetik provides the user with two different utilities
- Avg
- AvgDomain
for calculating the average values.
The Avg utillity
Avg(
divides the obtained value considering the specified dimensions by the number of set tuples that contributed to the value.
The AvgDomain utility
AvgDomain(
divides the obtained value considering the specified dimensions by the number of set tuples and which have not contributed to the value.
The following can be entered as input dimensional specifications for the functions Avg and AvgDomain:
- one or more specifications of Dim.Parent(
) type: in this case, each lowest level element related to a node of the specified hierarchy according to the Parent logic, will be associated with an amount equal to the average amounts present on the lowest level elements related to the same node according to the Parent logic; - one or more specifications of Dim.Ancestor(
, ) type: in this case, each lowest level element related to a node of the specified hierarchy according to the Ancestor logic, will be associated with an amount equal to the average amounts present on the lowest level elements related to the same node according to the Ancestor logic; - Time.PN: in this case, the average value of the n-tuple is associated to each n-tuple on the PN time interval;
- Time.Scenario: the average value of the n-tuple is associated to each n-tuple on the current scenario;
Example 1
Let us assume we have we have the node 01 of a hierarchy defined on the custom dimension 1 to which the elements D01, D02, D03, D04 are related and of a hierarchy defined on the custom dimension 1 to which the elements D01, D02, D03, D04 are related and that on such elements we have the following values
| Dest1 | Amount |
|---|---|
| D01 | 10 |
| D02 | 20 |
| D03 | 30 |
| D04 |
Then if we write
… := Avg ([C00000], Dest1.Parent([01]));
the result will be
| Dest1 | Amount |
|---|---|
| D01 | 60/3 = 20 |
| D02 | 60/3 = 20 |
| D03 | 60/3 = 20 |
while, if we write
… := AvgDomain ([C00000], Dest1.Parent([01]));
the result will be
| Dest1 | Amount |
|---|---|
| D01 | 60/4 = 15 |
| D02 | 60/4 = 15 |
| D03 | 60/4 = 15 |
| D04 | 60/4 = 15 |
.