TM1 Rest API to get the top level elements

Post Reply
kavitha2002
Community Contributor
Posts: 180
Joined: Sat May 05, 2018 11:48 am
OLAP Product: tm1
Version: 10.3.10100.8
Excel Version: 14

TM1 Rest API to get the top level elements

Post by kavitha2002 »

Hi,

I have a question reg. TM1 Restapi. I want to get the list of top-level elements from the dimension.

Is there any way to fetch? kindly suggest. Thanks

Admin Note: Subject line edited per BabyTiger's suggestion.
babytiger
Posts: 78
Joined: Wed Jul 31, 2013 4:32 am
OLAP Product: Cognos TM1, EP, Analyst
Version: 10.2.2
Excel Version: 2013
Location: Sydney AU

Re: TM1 Rest API to get the top level elements

Post by babytiger »

Filter by Parents, where count of parent =0.

Code: Select all

/api/v1/Dimensions('Dimension')/Hierarchies('Dimension')/Elements?$filter=Parents/$count eq 0 
Alternative is, create a dynamic subset, and have the rest api refer to the subsets [workaround].

Edit: Also I would suggest that you update the Subject of your post. It is pretty misleading.
MK
kavitha2002
Community Contributor
Posts: 180
Joined: Sat May 05, 2018 11:48 am
OLAP Product: tm1
Version: 10.3.10100.8
Excel Version: 14

Re: TM1 Rest api: How to get Head elements in Dimension

Post by kavitha2002 »

Hi am new to TM1,

Thanks for your quick reply. It works well.

But in Tm1 perpectives dimension structure is created as,

c A0
A1
A2
A3

N P0
C G0
G1

C A1
A11
A12

C s19
A0
A1
P0


In subset editor its shows the elements in same order..

So i want to filter A0, P0, G0, A1, S19 elements. Is there a way to do it in TM1 Restapi??

And Is it possible to get the child element if I pass the parent element. Example: Passing A0 -> will return A1, A2, A3 in Tm1 Restapi?

Kindly suggest me some solution.
babytiger
Posts: 78
Joined: Wed Jul 31, 2013 4:32 am
OLAP Product: Cognos TM1, EP, Analyst
Version: 10.2.2
Excel Version: 2013
Location: Sydney AU

Re: TM1 Rest API to get the top level elements

Post by babytiger »

For the dimension structure you have just created, what did the api code return? Isn't it giving you the 5 elements that you've mentioned?

With regards to your other question, I would like to point you to the IBM TM1 Rest API guide:
https://www.ibm.com/support/knowledgece ... -gen4.html

... and check out the schema section, in your case, have a read at the Element (entity section). TM1 dimension structures are generally built on "Parents" and "Components" (children).

Understand that you are new to TM1, but I would suggest getting some understanding of the TM1 fundamentals will help.
MK
kavitha2002
Community Contributor
Posts: 180
Joined: Sat May 05, 2018 11:48 am
OLAP Product: tm1
Version: 10.3.10100.8
Excel Version: 14

Re: TM1 Rest API to get the top level elements

Post by kavitha2002 »

Its not returning the 5 elements as I expect. Because only those two has no parents. Thats true but i want all the 5 elements.


/api/v1/Dimensions('Dimension')/Hierarchies('Dimension')/Elements?$filter=Parents/$count eq 0
returns S19, G0 for the above example.

/api/v1/Dimensions('Dimension')/Hierarchies('Dimension')?$expand=Elements
returns all the elements in the same order of how in TM1 perspectives its shown but gives all the components... that i dont want.

I will look into the Tm1 Restapi giude...
babytiger
Posts: 78
Joined: Wed Jul 31, 2013 4:32 am
OLAP Product: Cognos TM1, EP, Analyst
Version: 10.2.2
Excel Version: 2013
Location: Sydney AU

Re: TM1 Rest API to get the top level elements

Post by babytiger »

In your original post, you've asked for a rest query that returns the top level elements of a dimension. Top level means those elements without any parent, or have I missed something?

In the example you've given, the only 2 elements that do not have any parent are S19 and G0. Because A0 P0 and A1 all have parent(s), they are all rolling up to S19. While they are consolidation elements themselves, they are also child of another consolidation element, hence aren't top level elements. What you are seeing in your example is likely a default subset, but isn't the true hierarchy structure.
MK
kavitha2002
Community Contributor
Posts: 180
Joined: Sat May 05, 2018 11:48 am
OLAP Product: tm1
Version: 10.3.10100.8
Excel Version: 14

Re: TM1 Rest API to get the top level elements

Post by kavitha2002 »

What you have described is ture, but my requirement is different but my question was wrongly posted. The elements in Dimension has the same structure how its defined in Tm1 Perspectives.

The call from application as

/api/v1/Dimensions('Dimension')/Hierarchies('Dimension')?$expand=Elements($select=Name,Attributes,Type;$expand=Components($select=Name,Type);$expand=Parents($select=Name,Type))"

return the elements defined in Tm1 Perspectives, which is

c A0
A1
A2
A3

N P0
C G0
G1

C A1
A11
A12

C s19
A0
A1
P0

So i thought of having only the A0, P0, G0, A1, s19 which looks like top-level elements for me.

Sorry I am very new to TM1. And so for the discussion what we had is quite interesting and I got some clear idea. Thanks.
Post Reply