TM1 REST API - Getting alias value when retrieving native view

Post Reply
User avatar
Harvey
Community Contributor
Posts: 224
Joined: Mon Aug 04, 2008 4:43 am
OLAP Product: PA, TM1, CX, Palo
Version: TM1 8.3 onwards
Excel Version: 2003 onwards
Contact:

TM1 REST API - Getting alias value when retrieving native view

Post by Harvey » Thu Jan 21, 2021 4:40 am

Hi all,

I'm trying to retrieve and render a view using the REST API. I want to present it similarly to how it looks in Architect. Python is not an option in my dev environment -- so I must do so using native API calls via web request.

I've tried using tm1.Execute, but when the Axes are returned, I don't seem the get the "display name" of the tuples in the rows or columns, rather the raw element name:

Code: Select all

api/v1/Cubes('My Cube')/Views('My View')/tm1.Execute?$expand=Axes($expand=Hierarchies($select=Name),Tuples($expand=Members($select=Name))),Cells
returns

Code: Select all

{
    "Axes": [
        {
            "Ordinal": 0,
            "Cardinality": 1,
            "Hierarchies": [
                {
                    "Name": "Column Dimension"
                }
            ],
            "Tuples": [
                {
                    "Ordinal": 0,
                    "Members": [
                        {
                            "Name": "Measure 001"
                        }
                    ]
                }
            ]
        },
        {
            "Ordinal": 1,
            "Cardinality": 33,
            "Hierarchies": [
                {
                    "Name": "Row Dimension"
                }
            ],
            "Tuples": [
                {
                    "Ordinal": 0,
                    "Members": [
                        {
                            "Name": "Raw Element Name 001"
                        }
                    ]
                },
                {
                    "Ordinal": 1,
                    "Members": [
                        {
                            "Name": "Raw Element Name 002"
                        }
                    ]
                },
       ...
The Members returned are of type TupleMember, which contains:

Code: Select all

                        {
                            "Name": "Raw Element Name",
                            "UniqueName": "[Dimension Name].[Hierarchy Name].[Raw Element Name]",
                            "Type": "Regular",
                            "Ordinal": 27,
                            "IsPlaceholder": false,
                            "Weight": 1,
                            "Attributes": {
                                "Caption": "Raw Element Name",
                                "Display Name": "THE ATTRIBUTE I WANT"
                            },
                            "DisplayInfo": 131072,
                            "DisplayInfoAbove": 131072
                        }
I can see the attribute in the tuple data, but I still don't know which one to display if I have no knowledge of the view structure in advance.

So, I tried getting the selected attribute from the NativeView subset data using the following query:

Code: Select all

api/v1/Cubes('My Cube')/Views('My View')?$expand=tm1.NativeView/Rows/Subset($expand=Elements),tm1.NativeView/Columns/Subset($expand=Elements),tm1.NativeView/Titles/Subset($expand=Elements)
which returns:

Code: Select all

{
    "Name": "My View",
    "Attributes": {
        "Caption": "My View"
    },
    "Rows": [
        {
            "Subset": {
                "Name": "",
                "UniqueName": "",
                "Expression": null,
                "Attributes": {
                    "Caption": ""
                },
                "Elements": [
                    {
                        "Name": "Raw Element Name",
                        "UniqueName": "[Row Dimension].[Row Hierarchy].[Raw Element Name]",
                        "Type": "Numeric",
                        "Level": 0,
                        "Index": 2,
                        "Attributes": {
                            "Caption": "Raw Element Name",
                            "Display Name": "THE ATTRIBUTE I WANT"
                        }
                    },
                ...
It seems neither query gives me the selected attribute name -- although I really expected that to be part of the Subset object, if not included as a field in the TupleMember.

If anyone can provide advice on how to get this value, it would be much appreciated.

Cheers,
Harvey.
Take your TM1 experience to the next level - TM1Innovators.net

Post Reply