Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
iliasmansouri
New Contributor II

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
erik_wetterberg
Honored Contributor

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

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.

Erik Wetterberg
https://extendingqlik.upper88.com/
4 Replies
jesper_snihs
Contributor

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

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

iliasmansouri
New Contributor II

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

‌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

erik_wetterberg
Honored Contributor

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

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.

Erik Wetterberg
https://extendingqlik.upper88.com/
iliasmansouri
New Contributor II

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

Thank you very much Erik, just what I needed!

Community Browser