Hi,
Is there any Function to identify the position of the lement in a subset?
I am trying to find the element position under a hierarchy in a subset.
Example:-
Global-C
Europe-C
Belgium-S
Italy-S
France-S
America-C(Under global)
Newyork-S
Pheonix-S
In the above example, i want to get the Pheonix element position as 2 (since it is in the 2nd element in America Region).
Function to return the element order in the Hierarchy
-
- Posts: 32
- Joined: Fri May 27, 2011 9:06 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
- qml
- MVP
- Posts: 1096
- Joined: Mon Feb 01, 2010 1:01 pm
- OLAP Product: TM1 / Planning Analytics
- Version: 2.0.9 and all previous
- Excel Version: 2007 - 2016
- Location: London, UK, Europe
Re: Function to return the element order in the Hierarchy
From your question I'm not sure whether you're interested in checking the position of an element in a dimension, in a subset or in a specific hierarchy of your dimension. The order of elements in the subset doesn't have to have anything in common with the order of elements in a hierarchy.
If you want to check an element's position in a subset, the SUBIX function could be of use, except... it's not available in TM1. Therefore you will need to loop through your subset and compare the subsequent elements with the one you're looking for. Use the SUBSIZ and SUBNM functions in a TI process for this.
If you want to check an element's position in the hierarchy of its dimension (i.e. which child of its parent it is) you can use a smart combination of ELCOMP and ELCOMPN, but again you will have to create a loop in your TI.
That is, of course, if your original question was about a TI "function" at all. Maybe it was about an MDX function or a rule function, so maybe you can specify it a bit better.
If you want to check an element's position in a subset, the SUBIX function could be of use, except... it's not available in TM1. Therefore you will need to loop through your subset and compare the subsequent elements with the one you're looking for. Use the SUBSIZ and SUBNM functions in a TI process for this.
If you want to check an element's position in the hierarchy of its dimension (i.e. which child of its parent it is) you can use a smart combination of ELCOMP and ELCOMPN, but again you will have to create a loop in your TI.
That is, of course, if your original question was about a TI "function" at all. Maybe it was about an MDX function or a rule function, so maybe you can specify it a bit better.
Kamil Arendt
-
- Posts: 32
- Joined: Fri May 27, 2011 9:06 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Function to return the element order in the Hierarchy
Thanks for your Suggestion.
I have to delete the childs of different parents in a subset.
I need to check the attribute values of childs and if the att value of child is 0, then i need to delete that child from the parent through a TI process.
we are trying to delete the elements using the Index value where in it's not working. But we need to capture the element position and then remove the child value using the position number. Below is the code we are trying to achieve the functionality.
Please help.
V2 = 'Global';
v3=1;
while(v3<=ELCOMPN('es_country',V2));
v4 = ELCOMP('es_country',v2,v3);
v5=1;
While(V5<=ELCOMPN('es_country',V4));
V6 = ELCOMP('es_country',v4,v5);
if( Attrs('es_country',V6,'Flag') @='0');
V8 = DIMIX('es_country',V6);
SubsetElementDelete('es_country','Subset_delete',V5);
endif;
#asciioutput('D:\test123.txt',V6,numbertostring(V8));
v5=v5+1;
end;
v3=v3+1;
end;
Thanks in Advance.
I have to delete the childs of different parents in a subset.
I need to check the attribute values of childs and if the att value of child is 0, then i need to delete that child from the parent through a TI process.
we are trying to delete the elements using the Index value where in it's not working. But we need to capture the element position and then remove the child value using the position number. Below is the code we are trying to achieve the functionality.
Please help.
V2 = 'Global';
v3=1;
while(v3<=ELCOMPN('es_country',V2));
v4 = ELCOMP('es_country',v2,v3);
v5=1;
While(V5<=ELCOMPN('es_country',V4));
V6 = ELCOMP('es_country',v4,v5);
if( Attrs('es_country',V6,'Flag') @='0');
V8 = DIMIX('es_country',V6);
SubsetElementDelete('es_country','Subset_delete',V5);
endif;
#asciioutput('D:\test123.txt',V6,numbertostring(V8));
v5=v5+1;
end;
v3=v3+1;
end;
Thanks in Advance.
- qml
- MVP
- Posts: 1096
- Joined: Mon Feb 01, 2010 1:01 pm
- OLAP Product: TM1 / Planning Analytics
- Version: 2.0.9 and all previous
- Excel Version: 2007 - 2016
- Location: London, UK, Europe
Re: Function to return the element order in the Hierarchy
This looks like something that could easily be achieved using a dynamic subset. You could have an attribute to define which elements you want in your subset and a simple MDX formula would give you a subset that contains all the elements with Flag set to 1:
Once you have this subset defined, you can optionally choose to create a static copy of it (to improve performance by avoiding MDX recalculation) by simply cycling through it in a TI process and copying each element to another static subset.
Code: Select all
{FILTER( {TM1SUBSETALL( [es_country] )}, [es_country].[Flag] = 1)}
Kamil Arendt
-
- MVP
- Posts: 3701
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Function to return the element order in the Hierarchy
Or for that matter since you know the logic of what elements should be in the subset why struggle with the logic to get the current members and determine if they are correct. Simply SubsetDeleteAllElements and then loop through the dimension to add the correct members. Either way much simpler than what you are currently attempting.
-
- Posts: 32
- Joined: Fri May 27, 2011 9:06 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Function to return the element order in the Hierarchy
Many thnaks for your work arounds.
But how can i get the parent-child hierarchy in the subset with only childs with 0 att value? The momnet i add the parent it is inserting their childs into the subset again automatically. This is where we are struck.
if i get the dynamic subset, then all the childs with 0 attr value will be shown in that subset, but how should i get these childs under their respective parents?
Thanks for your patience.
But how can i get the parent-child hierarchy in the subset with only childs with 0 att value? The momnet i add the parent it is inserting their childs into the subset again automatically. This is where we are struck.
if i get the dynamic subset, then all the childs with 0 attr value will be shown in that subset, but how should i get these childs under their respective parents?
Thanks for your patience.
- qml
- MVP
- Posts: 1096
- Joined: Mon Feb 01, 2010 1:01 pm
- OLAP Product: TM1 / Planning Analytics
- Version: 2.0.9 and all previous
- Excel Version: 2007 - 2016
- Location: London, UK, Europe
Re: Function to return the element order in the Hierarchy
This is simply not true. Inserting a consolidated element into a subset does not mean its children are added to that subset. However, these children will be shown directly under their parent consolidation as soon as you click the expand ("+") symbol next to the consolidated element. This is a functionality of Subset Editor that cannot be switched off I'm afraid.Acc_Moonwalk wrote:The momnet i add the parent it is inserting their childs into the subset again automatically.
As a workaround (but not sure if it can be applied to your case) you can prevent users from being able to view specific elements by applying element-level security.
To sort elements in your MDX subset by hierarchy, just add {Hierarchize( )} around the code provided above - this should put children directly under their parents.
Kamil Arendt