Planning Analytics

 View Only
  • 1.  TM1 REST API - Private NativeView with private subsets

    IBM Champion
    Posted Fri April 19, 2024 11:21 AM

    Hi all

    When extracting a private native view and expanding the subsets, how can we determine whether the used subsets are private or public?

    The subset fields do not include this information:

    {
        "@odata.context": "../$metadata#Cubes('Calendar')/PrivateViews(Name,ibm.tm1.api.v1.NativeView/Rows/Subset)",
        "value": [
            {
                "@odata.etag": "W/\"6c5e53932f45293ca63964ad62617001aa7eee87\"",
                "@odata.type": "#ibm.tm1.api.v1.NativeView",
                "Name": "Private view",
                "Rows": [
                    {
                        "Subset": {
                            "@odata.etag": "W/\"2c18602a55c87881bf30ee9fe8293003f6cb2ddf\"",
                            "Name": "private subset",
                            "UniqueName": "[Calendar].[Calendar].[private subset]",
                            "Expression": null,
                            "Attributes": {
                                "Caption": "private subset"
                            }
                        }
                    }
                ]
            }
        ]
    Thanks!}


    ------------------------------
    Vlad Didenko
    Founder at Succeedium
    TeamOne Google Sheets add-on for IBM Planning Analytics / TM1
    https://succeedium.com/teamone/
    Succeedium Planning Analytics Cloud Extension
    https://succeedium.com/space/
    ------------------------------


  • 2.  RE: TM1 REST API - Private NativeView with private subsets

    Posted Fri April 19, 2024 01:01 PM

    If the dimname subset in question is not listed among the elements in the }Subsets_<dimname> dimension it is private; that should work.



    ------------------------------
    Walter Coffen
    Technology Manager
    QueBIT Consulting, LLC
    ------------------------------



  • 3.  RE: TM1 REST API - Private NativeView with private subsets

    IBM Champion
    Posted Fri April 19, 2024 01:12 PM

    Thank you @Walter Coffen, this is a good idea!

    I just wanted to clarify that I'm hoping to check each subset with a single API request.



    ------------------------------
    Vlad Didenko
    Founder at Succeedium
    TeamOne Google Sheets add-on for IBM Planning Analytics / TM1
    https://succeedium.com/teamone/
    Succeedium Planning Analytics Cloud Extension
    https://succeedium.com/space/
    ------------------------------



  • 4.  RE: TM1 REST API - Private NativeView with private subsets

    Posted 30 days ago

    Hi Vlad,

    Subsets by themselves are not public or private which is why there is no property of a subset that says so either, it is the location where a subset 'lives' that determines if a subset is public or private, hence the subset can be public, in which case you'll find it in the 'Subsets' collection of a hierarchy, or private, in which case you'll find it in the 'PrivateSubsets' of a hierarchy or a subset can even be private to a view, which can be the case in both public or a private view, in which case the subset is 'contained' within that view.

    The place where subsets live is only really visible by looking at the canonical URL of such subset which you can retrieve by using a $expand against the subset's /$ref. In your case I'm imagining you are using a `$expand=Rows($expand=Subset)`, by adding the $ref as in `$expand=Rows($expand=Subset/$ref)`, you'd get the @odata.id who's value is that canonical URL to the entity and therefore will contain that `Subsets` or `PrivateSubsets` path segment which you could use to determine if a subset is public, kept private or even is specific to a view (in which case the view itself is in the path - I'll let you figure that one out;-).

    FYI, there is no way unfortunately to do an expand and do an expand/$ref at the same time but if you do not include the key property in the $select TM1 v11 will inject the @odata.id to uniquely identify the entity as well. Note however that v12 in those cases injects the key property instead. As such it would be better to depend on the /$ref. If you need more information about the subset you can use that canonical URL returned by @odata.id to retrieve any additional information about the subset you'd need.

    Hope this helps!    



    ------------------------------
    Hubert Heijkers
    STSM, Program Director TM1 Functional Database Technology and OData Evangelist
    ------------------------------



  • 5.  RE: TM1 REST API - Private NativeView with private subsets

    IBM Champion
    Posted 28 days ago

    Thanks, Hubert, I appreciate your detailed answer!

    In my case, I'm trying to use a single API request to get the subset name or MDX or element list (which I believe you refer to as "a subset specific to a view") for each dimension:

    Cubes('MyCube}')/PrivateViews('MyPrivateView')?$expand=tm1.NativeView/Rows/Subset($expand=Hierarchy($select=Name;$expand=Dimension($select=Name)),Elements($select=Name);$select=Name,Expression,Alias)...
    If I understand your answer (please correct me if I'm wrong), you are saying I cannot expand $ref and other fields at the same time. (I did play a little bit, but no luck.)
    I was also able to verify your other point: If I don't include the Name in $select (which I believe is the key property), then I do get @odata.id with the subset URL included in the response.
    I suppose if I want to keep it in a single API request, my only option is to omit the Name and parse it from the @odata.id URL.
    Another option is to use a second API request to expand Subset/$ref and then combine both.
    Thank you once again for bringing these small nuances to my attention!


    ------------------------------
    Vlad Didenko
    Founder at Succeedium
    TeamOne Google Sheets add-on for IBM Planning Analytics / TM1
    https://succeedium.com/teamone/
    Succeedium Planning Analytics Cloud Extension
    https://succeedium.com/space/
    ------------------------------



  • 6.  RE: TM1 REST API - Private NativeView with private subsets

    Posted 22 days ago

    Hi Vlad,

    Well, actually, using full metadata in OData, you can get everything in one response (read: both the @odata.id as well as the properties) but you'd also get the association and navigation links for any navigation properties you are not expanding so it might be a bit verbose, yet you could. In that case you would expand using the `/$ref` but you'd expand the subset but add the "odata.metadata=full" to either the Accept header or the $format query option as in `application/json;odata.metadata=full` as the value for either. Note that the default behavior is to return minimal metadata.

    Omitting the name only works in TM1 v11. If you want to make your solution future proof and work with TM1 v12 as well then that no longer will work unfortunately as in that case we'll inject the key property instead of the @odata.id if you omit the key property in the select.

    Hope this helps!

    The only way to get it all would be a request asking for full metadata, but then you get it all ;-)



    ------------------------------
    Hubert Heijkers
    STSM, Program Director TM1 Functional Database Technology and OData Evangelist
    ------------------------------



  • 7.  RE: TM1 REST API - Private NativeView with private subsets

    IBM Champion
    Posted 22 days ago

    Thanks Hubert!

    In my API request, I'm also expanding the elements and with data.metadata=full, it returns too much unnecessary metadata, which may negatively impact the UI performance.

    I think that your initial suggestion to expand only the `$ref` property is the most optimal solution. Even if several extra API requests are required to retrieve subset details, they would still be very fast. When expanding elements for large view-specific subsets, I could check the element count and use `$top/$skip` to retrieve elements in my UI. This would ensure that I don't overload the browser.



    ------------------------------
    Vlad Didenko
    Founder at Succeedium
    TeamOne Google Sheets add-on for IBM Planning Analytics / TM1
    https://succeedium.com/teamone/
    Succeedium Planning Analytics Cloud Extension
    https://succeedium.com/space/
    ------------------------------