Filters
The concept of filter is very important for designing a TGKML, script since it allows to "limit":
- the set of input data;
- data to delete;
- data to save to the output cube
The only mandatory filter in the syntax of a TGKML script is the filter on the Time dimension.
The possible filters are:
- prompt filters. These are applied to all the MD calculation logics run from the application's web interface, from the data entry form, from the workflow model related to an application process, from the process cockpit etc. A typical example is the run of a set of MD calculation logics only for the A00 Entity;
- filters on account dimension. These are applied to the single input account present in the assignment of a given TGKML script;
- filters on an assignment. These are applied to a single "assignment" part of the TGKML script and can be considered as an additional restriction to the prompt filters. For example an assignment might read and write only from/on a subset of cost centers (managed on the custom dimension 1).
The syntax to use to define an input or output filter is the following:
Dimension.Filter([...])
The syntax to use in the case of filter on FST item (input) is:
{
For example it is possible to write
- Entity.Filter([A00]) to filter on the entity A00;
- Entity.Filter([A00],[A01]) to filter on the entity A00 and on the entity A01;
- Entity.Filter([01|$]) to filter on all the entities related to the node $ of the hierarchy 01.
Input filters¶
Let's see some examples of input filters definition.
Example 1
Let us assume that we have the following set of input data:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount |
|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 |
| A00 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 |
| A00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 |
and to define the input part of the script as follows:
… := [X00000](Dest1.Filter([D11]), Dest2.Filter([D22]))
Then the system reads the following set of data:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount |
|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 |
Example 2
Let us assume that we have the following set of input data:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 | PROC_CALCULATED |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | PROC_CALCULATED |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
| C00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
and to define the input part of the script as follows:
... := [LO].[X00000](Entity.Filter([A00],[A01],[A02]))
and that we have defined, at the script runtime, a prompt filter on the elements A00, A01 of the entity dimension.
Thus the system reads the following set of data:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 | PROC_CALCULATED |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | PROC_CALCULATED |
Output filters¶
Let's see some examples of output filters definition.
Example1
Let us assume that we have the following syntax
[LO].[X00000](Dest1.Filter([D11], [01|$])) :=...
in this case the system deletes and then saves the original gross amounts related to the account X00000 on the element D11 of the custom dimension 1 and on all the elements of the custom dimension 1 related to the node $ of the hierarchy 01.
On the other hand, if we have
[LO].[X00000](Entity.Filter([A00])) :=...
the system deletes and then saves original gross amounts related to the account X00000 only for the Entity A00.
Example 2
Let us assume that:
- we have defined the Output part of the script as follows [LO].[X00000](Entity.Filter([A00],[A01],[A02])) := ...
- we have a prompt filter on the elements A00, A01,A02 of the entity dimension;
- we have the following set of data before the deletion:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 | PROC_CALCULATED |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | PROC_CALCULATED |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
| C00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
The system deletes and saved the gross amounts for the account X00000 and the entities A00,A01,A02.
After the deletion, following data are on the database:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| C00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
Example 3
Let us assume that:
- we have defined the Output part of the script as follows [LO].[X00000](Entity.Filter([A00],[A01],[A02])) := ...
- we have a prompt filter on the element A00 of the entity dimension;
- we have always the same set of data before the deletion of the former example
The system deletes and saves gross data for the account X00000 and the entity A00.
Following data are present after the deletion:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | PROC_CALCULATED |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
| C00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | PROC_CALCULATED |
Example 4
Let us assume that:
- we have defined the following script [LO].[X00000] := [C00000](Entity.Filter([A00]));
- we have a prompt filter on the elements A00, A01,A02 of the entity dimension;
- that the value calculated by the script for the entity A00 is equal to 50;
Moreover, let us assume that data on the database before running the script are the following:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 | INPUT_DEFORM |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | INPUT_DEFORM |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | INPUT_DEFORM |
| C00 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | INPUT_DEFORM |
Data present after the script run are the following:
| Entity | Account | Scenario | Category | Dest1 | Dest2 | Amount | Origin |
|---|---|---|---|---|---|---|---|
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | 150 | INPUT_DEFORM |
| A00 | X00000 | 2013BDG | $AMOUNT | GEN | GEN | -100 | PROC_CALCULATED |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | 80 | INPUT_DEFORM |
| A01 | X00000 | 2013BDG | $AMOUNT | D11 | D21 | -80 | PROC_CALCULATED |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | 30 | INPUT_DEFORM |
| A02 | X00000 | 2013BDG | $AMOUNT | D11 | D22 | -30 | PROC_CALCULATED |
When a filter is applied only to the input part of the script, depending on how the prompt filters are set, the system might reset data which are out of the filter scope (resulting from the intersection of the prompt filters with the filters of the single assignment).