Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to ask for a list of dimensions and measures in Qlik Engine API?

Hi all,

Using the Sales Discovery example, how can I construct a json which will ask for a list of dimensions and measures?

So using the Qlik Engine API, I would like something like:

{

     "handle": 1, #Handle of Sales Discovery app

     "method": "GetListofMeasures_and_Dims",

     "params": {}

}

Thanks in advance

1 Solution

Accepted Solutions
ErikWetterberg

Hi

Have you tried the Engine API explorer? It helps you construct Engine API Explorer messages. You find it at http://localhost:4848/dev-hub/engine-api-explorer for Qlik Sense Desktop.    

If you connect to engine and open an app you will find a list of macros, among them 'List Measures' and 'List Dimensions'. The 'List Measures' Macros will give you something like this:

{

   "method": "CreateSessionObject",

   "handle": 1,

   "params": [

   {

      "qInfo": {

         "qType": "MeasureList"

      },

      "qMeasureListDef": {

         "qType": "measure",

         "qData": {

            "title": "/title",

            "tags": "/tags"

         }

      }

   }

   ],

   "outKey": -1,

   "id": 3

}

To actually get the data you would need to call first CreateSessionsObject and then GetLayout using the handle you get in return from the first command. Also I'm afraid the macro is not very good, since you will get all measures but really not any data about them, like definition etc. If you modify the qData part and do something like this:

"qData": {

   "title": "/title",

   "tags": "/tags",

   "measure": "/qMeasure"

}

It will be more useful.

Then you can add a qDimensionList section to the same CreateSessionObject command and you will get Dimensions to in the same message.

Hope this helps

Erik Wetterberg

Please marks as correct and/or helpful if you find the answer helps you.

View solution in original post

4 Replies
_jespers_
Partner - Creator II
Partner - Creator II

Hi Illias,

Is it a requirement that you need to use the Qlik Engine API?

Otherwise you can set the initial properties to fetch the measures and dimensions in the application and you will then find them in the layout property.

Example code:

define( [

        'jquery',

        'text!./template.html',

        'qlik'

    ],

    function ( $, template, qlik ) {

        'use strict';

        return {

            initialProperties: {

                qMeasureListDef:{

                    qType: 'measure'

                },

                qDimensionListDef:{

                    qType: 'dimension'

                }

            },

            support: {

                snapshot: false,

                export: false,

                exportData: false

            },

            template: template,

            paint: function ($element, layout) {

                console.log("layout.qDimensionList", layout.qDimensionList);

                console.log("layout.qMeasureList", layout.qMeasureList);

                return qlik.Promise.resolve();

            },

            controller: ['$scope', function($scope){

            }]

        };

    });

Regards

Jesper

Anonymous
Not applicable
Author

‌Hi Jesper,

FIrst of all, thanks for your kind feedback. Unfortunately due to the set of constraints, using the Qlik Engine API is the only solution.

KInd regards,

Ilias

ErikWetterberg

Hi

Have you tried the Engine API explorer? It helps you construct Engine API Explorer messages. You find it at http://localhost:4848/dev-hub/engine-api-explorer for Qlik Sense Desktop.    

If you connect to engine and open an app you will find a list of macros, among them 'List Measures' and 'List Dimensions'. The 'List Measures' Macros will give you something like this:

{

   "method": "CreateSessionObject",

   "handle": 1,

   "params": [

   {

      "qInfo": {

         "qType": "MeasureList"

      },

      "qMeasureListDef": {

         "qType": "measure",

         "qData": {

            "title": "/title",

            "tags": "/tags"

         }

      }

   }

   ],

   "outKey": -1,

   "id": 3

}

To actually get the data you would need to call first CreateSessionsObject and then GetLayout using the handle you get in return from the first command. Also I'm afraid the macro is not very good, since you will get all measures but really not any data about them, like definition etc. If you modify the qData part and do something like this:

"qData": {

   "title": "/title",

   "tags": "/tags",

   "measure": "/qMeasure"

}

It will be more useful.

Then you can add a qDimensionList section to the same CreateSessionObject command and you will get Dimensions to in the same message.

Hope this helps

Erik Wetterberg

Please marks as correct and/or helpful if you find the answer helps you.

Anonymous
Not applicable
Author

Thank you very much Erik, just what I needed!