IBM TM1 (Planning Analytics) - Cube view to Datagrid in C#

257 views Asked by At

I'm working to get a Cube View to my Datagrid in C#, I setup the login and everything around, now I mess up with the Cubeview and Values.

I tried to Call:

api/v1/Cubes('{{cubeName}}')/Views('{{viewName}}')?$expand=tm1.NativeView/Columns/Subset($expand=Elements)

Here I got things like:

{
"@odata.context": "../$metadata#Cubes('Personalbedarf-Planung')/Views/ibm.tm1.api.v1.NativeView(Columns/Subset(Elements))/$entity",
"@odata.etag": "W/\"1f63d325e92bbcfc1f7a705363620d89509b5e0f\"",
"@odata.type": "#ibm.tm1.api.v1.NativeView",
"Name": "Standard",
"Attributes": {
    "Caption": "Standard"
},
"Columns": [
    {
        "Subset": {
            "@odata.etag": "W/\"473094365ea8b99a078d6be1dfb54b592763b03a\"",
            "Name": "",
            "UniqueName": "",
            "Expression": null,
            "Attributes": {
                "Caption": ""
            },
            "Elements": [
                {
                    "@odata.etag": "W/\"081305b77ecb988541df30389919144adf984183\"",
                    "Name": "Stand rMA inkl. EAT",
                    "UniqueName": "[Kennzahlen Personalbedarf-Planung].[Kennzahlen Personalbedarf-Planung].[Stand rMA inkl. EAT]",
                    "Type": "Consolidated",
                    "Level": 1,
                    "Index": 36,
                    "Attributes": {
                        "Caption": "Stand rMA inkl. EAT",
                        "temp1": "Stand rMA inkl. EAT",
                        "temp": "Stand rMA inkl. EAT",
                        "Format": "#,##0.00"
                    }
                },
                {
                    "@odata.etag": "W/\"68f5e1627b4f26707ab39068ab15567604c89ec5\"",
                    "Name": "Stand rMA",
                    "UniqueName": "[Kennzahlen Personalbedarf-Planung].[Kennzahlen Personalbedarf-Planung].[Stand rMA]",
                    "Type": "Numeric",
                    "Level": 0,
                    "Index": 37,
                    "Attributes": {
                        "Caption": "Stand rMA",
                        "temp1": "Stand rMA",
                        "temp": "Stand Bedarf rMA",
                        "Format": "#,##0.00"
                    }
                },
                {
                    "@odata.etag": "W/\"10a7739607c0cb67b89655888d46f38630ed7fdd\"",
                    "Name": "Expert Agent Trainer rMA",
                    "UniqueName": "[Kennzahlen Personalbedarf-Planung].[Kennzahlen Personalbedarf-Planung].[Expert Agent Trainer rMA]",
                    "Type": "Numeric",
                    "Level": 0,
                    "Index": 38,
                    "Attributes": {
                        "Caption": "Expert Agent Trainer rMA",
                        "temp1": "Expert Agent Trainer rMA",
                        "temp": "Expert Agent Trainer rMA",
                        "Format": "#,##0.00"
                    }
                },
                {
                    "@odata.etag": "W/\"503fde2dd865b4629fca0dd3ed6117df7e865687\"",
                    "Name": "Abwesenheiten %",
                    "UniqueName": "[Kennzahlen Personalbedarf-Planung].[Kennzahlen Personalbedarf-Planung].[Abwesenheiten %]",
                    "Type": "Consolidated",
                    "Level": 1,
                    "Index": 21,
                    "Attributes": {
                        "Caption": "Abwesenheiten %",
                        "temp1": "Abwesenheiten %",
                        "temp": "Abwesenheiten %",
                        "Format": "#.00%"
                    }
                },
                {
                    "@odata.etag": "W/\"5191242ce06796a04cf00190df713882c092fa11\"",
                    "Name": "Brutto rMA",
                    "UniqueName": "[Kennzahlen Personalbedarf-Planung].[Kennzahlen Personalbedarf-Planung].[Brutto rMA]",
                    "Type": "Consolidated",
                    "Level": 2,
                    "Index": 41,
                    "Attributes": {
                        "Caption": "Brutto rMA",
                        "temp1": "Brutto rMA",
                        "temp": "Brutto rMA",
                        "Format": "#,##0.00"
                    }
                },'

I have an other call to get the Values for that:

{{protocol}}://{{serverName}}:{{httpPortNumber}}/api/v1/Cubes('{{cubeName}}')/Views('{{viewName}}')/tm1.Execute?$expand=Cells

This gives me this response:

{
"@odata.context": "../../$metadata#Cellsets(Cells)/$entity",
"ID": "XSURyJINAIApAAAg",
"Cells": [
    {
        "Ordinal": 0,
        "Value": 233.586573893022234,
        "FormattedValue": "233.59"
    },
    {
        "Ordinal": 1,
        "Value": 156.764861863236547,
        "FormattedValue": "156.76"
    },
    {
        "Ordinal": 2,
        "Value": 36.4955678453332766,
        "FormattedValue": "36.50"
    },
    {
        "Ordinal": 3,
        "Value": 11.0285294802793725,
        "FormattedValue": "11.03"
    },
    {
        "Ordinal": 4,
        "Value": 29.2976147041730144,
        "FormattedValue": "29.30"
    },
    {
        "Ordinal": 5,
        "Value": 230.32942731235994,
        "FormattedValue": "230.33"
    },
    {
        "Ordinal": 6,
        "Value": 153.953619472302137,
        "FormattedValue": "153.95"
    },
    {
        "Ordinal": 7,
        "Value": 36.3686083498840986,
        "FormattedValue": "36.37"
    },
    {
        "Ordinal": 8,
        "Value": 10.8456770212629792,
        "FormattedValue": "10.85"
    },
    {
        "Ordinal": 9,
        "Value": 29.161522468910718,
        "FormattedValue": "29.16"
    },
    {
        "Ordinal": 10,
        "Value": 3.2571465806622828,
        "FormattedValue": "3.26"
    },
    {
        "Ordinal": 11,
        "Value": 2.81124239093441286,
        "FormattedValue": "2.81"
    },
    {
        "Ordinal": 12,
        "Value": 0.126959495449180448,
        "FormattedValue": "0.13"
    },
    {
        "Ordinal": 13,
        "Value": 0.182852459016393992,
        "FormattedValue": "0.18"
    },
    {
        "Ordinal": 14,
        "Value": 0.136092235262295524,
        "FormattedValue": "0.14"
    },
    {
        "Ordinal": 15,
        "Value": 0.267346037406735126,
        "FormattedValue": "26.73%"
    },
    {
        "Ordinal": 16,
        "Value": 0.271828247861979733,
        "FormattedValue": "27.18%"
    },
    {
        "Ordinal": 17,
        "Value": 0.257814593932379099,
        "FormattedValue": "25.78%"
    },
    {
        "Ordinal": 18,
        "Value": 0.311820047597782868,
        "FormattedValue": "31.18%"
    },
    {
        "Ordinal": 19,
        "Value": 0.247224556597145928,
        "FormattedValue": "24.72%"
    },
    {
        "Ordinal": 20,
        "Value": 230.32942731235994,
        "FormattedValue": "230.33"
    },
    {
        "Ordinal": 21,
        "Value": 153.953619472302137,
        "FormattedValue": "153.95"
    },
    {
        "Ordinal": 22,
        "Value": 36.3686083498840986,
        "FormattedValue": "36.37"
    },
    {
        "Ordinal": 23,
        "Value": 10.8456770212629792,
        "FormattedValue": "10.85"
    },
    {
        "Ordinal": 24,
        "Value": 29.161522468910718,
        "FormattedValue": "29.16"
    },
    {
        "Ordinal": 25,
        "Value": 0.643851051641126881,
        "FormattedValue": "64.39%"
    },
    {
        "Ordinal": 26,
        "Value": 0.673075152870805438,
        "FormattedValue": "67.31%"
    },
    {
        "Ordinal": 27,
        "Value": 0.630763138000420609,
        "FormattedValue": "63.08%"
    },
    {
        "Ordinal": 28,
        "Value": 0.43347268986779558,
        "FormattedValue": "43.35%"
    },
    {
        "Ordinal": 29,
        "Value": 0.582456154073230259,
        "FormattedValue": "58.25%"
    },
    {
        "Ordinal": 30,
        "Value": 231.224025980634678,
        "FormattedValue": "231.22"
    },
    {
        "Ordinal": 31,
        "Value": 157.396839686503,
        "FormattedValue": "157.40"
    },
    {
        "Ordinal": 32,
        "Value": 33.5708079788121765,
        "FormattedValue": "33.57"
    },
    {
        "Ordinal": 33,
        "Value": 10.5744690446108631,
        "FormattedValue": "10.57"
    },
    {
        "Ordinal": 34,
        "Value": 29.6819092707086618,
        "FormattedValue": "29.68"
    },
    {
        "Ordinal": 35,
        "Value": 227.264025980634671,
        "FormattedValue": "227.26"
    },
    {
        "Ordinal": 36,
        "Value": 154.036839686502987,
        "FormattedValue": "154.04"
    },
    {
        "Ordinal": 37,
        "Value": 33.3708079788121736,
        "FormattedValue": "33.37"
    },
    {
        "Ordinal": 38,
        "Value": 10.3744690446108638,
        "FormattedValue": "10.37"
    },
    {
        "Ordinal": 39,
        "Value": 29.4819092707086625,
        "FormattedValue": "29.48"
    },
    {
        "Ordinal": 40,
        "Value": 3.96000000000000041,
        "FormattedValue": "3.96"
    },
    {
        "Ordinal": 41,
        "Value": 3.35999999999999988,
        "FormattedValue": "3.36"
    },
    {
        "Ordinal": 42,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 43,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 44,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 45,
        "Value": 0.24913562061586092,
        "FormattedValue": "24.91%"
    },
    {
        "Ordinal": 46,
        "Value": 0.266484593436904449,
        "FormattedValue": "26.65%"
    },
    {
        "Ordinal": 47,
        "Value": 0.19350669745038418,
        "FormattedValue": "19.35%"
    },
    {
        "Ordinal": 48,
        "Value": 0.250381688448402029,
        "FormattedValue": "25.04%"
    },
    {
        "Ordinal": 49,
        "Value": 0.229860544219707807,
        "FormattedValue": "22.99%"
    },
    {
        "Ordinal": 50,
        "Value": 227.264025980634671,
        "FormattedValue": "227.26"
    },
    {
        "Ordinal": 51,
        "Value": 154.036839686502987,
        "FormattedValue": "154.04"
    },
    {
        "Ordinal": 52,
        "Value": 33.3708079788121736,
        "FormattedValue": "33.37"
    },
    {
        "Ordinal": 53,
        "Value": 10.3744690446108638,
        "FormattedValue": "10.37"
    },
    {
        "Ordinal": 54,
        "Value": 29.4819092707086661,
        "FormattedValue": "29.48"
    },
    {
        "Ordinal": 55,
        "Value": 0.617456711400449887,
        "FormattedValue": "61.75%"
    },
    {
        "Ordinal": 56,
        "Value": 0.66474256463992909,
        "FormattedValue": "66.47%"
    },
    {
        "Ordinal": 57,
        "Value": 0.566487077833762953,
        "FormattedValue": "56.65%"
    },
    {
        "Ordinal": 58,
        "Value": 0.319493055986466101,
        "FormattedValue": "31.95%"
    },
    {
        "Ordinal": 59,
        "Value": 0.544580288009452906,
        "FormattedValue": "54.46%"
    },
    {
        "Ordinal": 60,
        "Value": 232.202727733422336,
        "FormattedValue": "232.20"
    },
    {
        "Ordinal": 61,
        "Value": 156.325438247076022,
        "FormattedValue": "156.33"
    },
    {
        "Ordinal": 62,
        "Value": 34.5582978232530778,
        "FormattedValue": "34.56"
    },
    {
        "Ordinal": 63,
        "Value": 11.2863654942776321,
        "FormattedValue": "11.29"
    },
    {
        "Ordinal": 64,
        "Value": 30.0326261688156073,
        "FormattedValue": "30.03"
    },
    {
        "Ordinal": 65,
        "Value": 228.242727733422328,
        "FormattedValue": "228.24"
    },
    {
        "Ordinal": 66,
        "Value": 152.965438247076008,
        "FormattedValue": "152.97"
    },
    {
        "Ordinal": 67,
        "Value": 34.3582978232530749,
        "FormattedValue": "34.36"
    },
    {
        "Ordinal": 68,
        "Value": 11.0863654942776328,
        "FormattedValue": "11.09"
    },
    {
        "Ordinal": 69,
        "Value": 29.832626168815608,
        "FormattedValue": "29.83"
    },
    {
        "Ordinal": 70,
        "Value": 3.96000000000000041,
        "FormattedValue": "3.96"
    },
    {
        "Ordinal": 71,
        "Value": 3.35999999999999988,
        "FormattedValue": "3.36"
    },
    {
        "Ordinal": 72,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 73,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 74,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 75,
        "Value": 0.241833578358898571,
        "FormattedValue": "24.18%"
    },
    {
        "Ordinal": 76,
        "Value": 0.255767929458084908,
        "FormattedValue": "25.58%"
    },
    {
        "Ordinal": 77,
        "Value": 0.201766013060114213,
        "FormattedValue": "20.18%"
    },
    {
        "Ordinal": 78,
        "Value": 0.28268162567850641,
        "FormattedValue": "28.27%"
    },
    {
        "Ordinal": 79,
        "Value": 0.203183477682120861,
        "FormattedValue": "20.32%"
    },
    {
        "Ordinal": 80,
        "Value": 228.242727733422328,
        "FormattedValue": "228.24"
    },
    {
        "Ordinal": 81,
        "Value": 152.965438247076008,
        "FormattedValue": "152.97"
    },
    {
        "Ordinal": 82,
        "Value": 34.3582978232530749,
        "FormattedValue": "34.36"
    },
    {
        "Ordinal": 83,
        "Value": 11.0863654942776328,
        "FormattedValue": "11.09"
    },
    {
        "Ordinal": 84,
        "Value": 29.832626168815608,
        "FormattedValue": "29.83"
    },
    {
        "Ordinal": 85,
        "Value": 0.635100542918187516,
        "FormattedValue": "63.51%"
    },
    {
        "Ordinal": 86,
        "Value": 0.673605370423311034,
        "FormattedValue": "67.36%"
    },
    {
        "Ordinal": 87,
        "Value": 0.602632066549569356,
        "FormattedValue": "60.26%"
    },
    {
        "Ordinal": 88,
        "Value": 0.338544512805122433,
        "FormattedValue": "33.85%"
    },
    {
        "Ordinal": 89,
        "Value": 0.58785681216002672,
        "FormattedValue": "58.79%"
    },
    {
        "Ordinal": 90,
        "Value": 233.218466401799247,
        "FormattedValue": "233.22"
    },
    {
        "Ordinal": 91,
        "Value": 153.547391647024199,
        "FormattedValue": "153.55"
    },
    {
        "Ordinal": 92,
        "Value": 37.853574150268571,
        "FormattedValue": "37.85"
    },
    {
        "Ordinal": 93,
        "Value": 10.7312140656421526,
        "FormattedValue": "10.73"
    },
    {
        "Ordinal": 94,
        "Value": 31.086286538864325,
        "FormattedValue": "31.09"
    },
    {
        "Ordinal": 95,
        "Value": 229.25846640179924,
        "FormattedValue": "229.26"
    },
    {
        "Ordinal": 96,
        "Value": 150.187391647024185,
        "FormattedValue": "150.19"
    },
    {
        "Ordinal": 97,
        "Value": 37.6535741502685681,
        "FormattedValue": "37.65"
    },
    {
        "Ordinal": 98,
        "Value": 10.5312140656421533,
        "FormattedValue": "10.53"
    },
    {
        "Ordinal": 99,
        "Value": 30.8862865388643257,
        "FormattedValue": "30.89"
    },
    {
        "Ordinal": 100,
        "Value": 3.96000000000000041,
        "FormattedValue": "3.96"
    },
    {
        "Ordinal": 101,
        "Value": 3.35999999999999988,
        "FormattedValue": "3.36"
    },
    {
        "Ordinal": 102,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 103,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 104,
        "Value": 0.200000000000000094,
        "FormattedValue": "0.20"
    },
    {
        "Ordinal": 105,
        "Value": 0.226552612920667085,
        "FormattedValue": "22.66%"
    },
    {
        "Ordinal": 106,
        "Value": 0.224228421715713139,
        "FormattedValue": "22.42%"
    },
    {
        "Ordinal": 107,
        "Value": 0.261536954717739301,
        "FormattedValue": "26.15%"
    },
    {
        "Ordinal": 108,
        "Value": 0.233768155243932935,
        "FormattedValue": "23.38%"
    },
    {
        "Ordinal": 109,
        "Value": 0.190632295737247437,
        "FormattedValue": "19.06%"
    },
    {
        "Ordinal": 110,
        "Value": 226.740958310568828,
        "FormattedValue": "226.74"
    },
    {
        "Ordinal": 111,
        "Value": 147.669883555793774,
        "FormattedValue": "147.67"
    },
    {
        "Ordinal": 112,
        "Value": 37.6535741502685681,
        "FormattedValue": "37.65"
    },
    {
        "Ordinal": 113,
        "Value": 10.5312140656421533,
        "FormattedValue": "10.53"
    },
    {
        "Ordinal": 114,
        "Value": 30.8862865388643257,
        "FormattedValue": "30.89"
    },
    {
        "Ordinal": 115,
        "Value": 0.635976030160744887,
        "FormattedValue": "63.60%"
    },
    {
        "Ordinal": 116,
        "Value": 0.682691579712871643,
        "FormattedValue": "68.27%"
    },
    {
        "Ordinal": 117,
        "Value": 0.596726184898497269,
        "FormattedValue": "59.67%"
    },
    {
        "Ordinal": 118,
        "Value": 0.341446066671711568,
        "FormattedValue": "34.14%"
    },
    {
        "Ordinal": 119,
        "Value": 0.560960185794971533,
        "FormattedValue": "56.10%"
    },
    {
        "Ordinal": 120,
        "Value": 234.637037853558923,
        "FormattedValue": "234.64"
    },
    {
        "Ordinal": 121,
        "Value": 157.367738796652219,
        "FormattedValue": "157.37"
    },
    {
        "Ordinal": 122,
        "Value": 37.158635982037481,
        "FormattedValue": "37.16"
    },
    {
        "Ordinal": 123,
        "Value": 10.4079459615768126,
        "FormattedValue": "10.41"
    },
    {
        "Ordinal": 124,
        "Value": 29.7027171132924188,
        "FormattedValue": "29.70"
    },
    {
        "Ordinal": 125,
        "Value": 230.977037853558926,
        "FormattedValue": "230.98"
    },
    {
        "Ordinal": 126,
        "Value": 154.007738796652205,
        "FormattedValue": "154.01"
    },
    {
        "Ordinal": 127,
        "Value": 37.0586359820374796,
        "FormattedValue": "37.06"
    },
    {
        "Ordinal": 128,
        "Value": 10.307945961576813,
        "FormattedValue": "10.31"
    },
    {
        "Ordinal": 129,
        "Value": 29.6027171132924174,
        "FormattedValue": "29.60"
    },
    {
        "Ordinal": 130,
        "Value": 3.66000000000000014,
        "FormattedValue": "3.66"
    },
    {
        "Ordinal": 131,
        "Value": 3.35999999999999988,
        "FormattedValue": "3.36"
    },
    {
        "Ordinal": 132,
        "Value": 0.100000000000000047,
        "FormattedValue": "0.10"
    },
    {
        "Ordinal": 133,
        "Value": 0.100000000000000047,
        "FormattedValue": "0.10"
    },
    {
        "Ordinal": 134,
        "Value": 0.100000000000000047,
        "FormattedValue": "0.10"
    },
    {
        "Ordinal": 135,
        "Value": 0.232135879172083837,
        "FormattedValue": "23.21%"
    },
    {
        "Ordinal": 136,
        "Value": 0.226478567508696771,
        "FormattedValue": "22.65%"
    }.......

I learned how I can patch and get single values also to get Cube lists and Dimensions lists etc.

But I cannot figure out how to combine this calls to a datagrid in C#.

Sorry I'm very unfamiliar with Json, read a lot of tutorials, but now I searching a answer for more then a week.

1

There are 1 answers

0
MNI On BEST ANSWER

I'm also a newbee, but maybe these informatins can help.

At the moment your outcoming JSON have only the values, but no informaions about the dimension elements.

  • Design your view in that case, that you have only 1 Dimensionelement in Column and all other needed Dimensions with Elements in Rows.
  • Change your calling Request to.

These should give you back an JSON with dimension elements and values:

{{protocol}}: // {{serverName}}: {{httpPortNumber}} / api / v1 / Cubes ('{{cubeName}}') / Views ('{{viewName}}') /tm1.Execute? $ expand = Ejes ($ expand = Jerarquías ($ select = Nombre), Tuplas ($ expand = Miembros ($ select = Nombre))), Celdas

Please try it out.