Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

APIs to retrieve expressions used for a measure

Hi,

Using the Qlik engine APIs, I am able to retrieve list of measures used in an application from my web app, but I can't find anything to also get the expressions used for measures.

Any help in this regard is appreciable.

Thanks in advance

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

In your definition of the Measurelist you need to say what data you want to get for each measure by defining qData.

In the capabilities API you can do like this:

app.createGenericObject({

                qInfo: {

                    qType: "MeasureList"

                },

                qMeasureListDef: {

                    qType: "measure",

                    qData: {

                        qMeasure: "/qMeasure"

                    }

                }

            }, setData);

Hope this helps

Erik Wetterberg

View solution in original post

9 Replies
ErikWetterberg

Hi,

In your definition of the Measurelist you need to say what data you want to get for each measure by defining qData.

In the capabilities API you can do like this:

app.createGenericObject({

                qInfo: {

                    qType: "MeasureList"

                },

                qMeasureListDef: {

                    qType: "measure",

                    qData: {

                        qMeasure: "/qMeasure"

                    }

                }

            }, setData);

Hope this helps

Erik Wetterberg

Anonymous
Not applicable
Author

Thanks a lot Erik. I came back from vacation and checked it, it is absolutely working fine.

cheers!!

Kiriti

ajaykakkar93
Specialist III
Specialist III

can we do that for Dimension as well , can you give an example

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

ErikWetterberg

Hi,

For dimensions it would be something like:

qDimensionListDef: {

     qType: "dimension",

     qData: {

          qDim: "/qDim",

          qDimInfos: "/qDimInfos"

     }

}

Erik Wetterberg

ajaykakkar93
Specialist III
Specialist III

Thanks Erik it worked

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

Anonymous
Not applicable
Author

Hi I would like to understand what this setData does?

I am creating the request this way:

  app.createSessionObject({

  qInfo: {

  qId: 'mysessionobject',

  qType: 'list'

  },


  qMeasureListDef : {

  qType: "measure", qData: { title: "/title", tags: "/tags", measure: "/qMeasure"  },

  qInitialDataFetch: [{

  "method": "GetLayout",

  "handle": 2,

  "params": [],

  "outKey": -1,

  "id": 4

  }]

  }

And printing it out to the console like this:

  myObject.forEach(element =>{

  console.log(element.qMeta.title + ' : ' + element.qMeta.description + ' : ' + element.qData.measure);

  console.log()

  });

What returns to my console is this:

Sales : Sum of sales amount. : [object Object]


So qMeasure is not returning the expression you know how this can be fixed?

bc1
Contributor III
Contributor III

i know this is an old topic but it would really help my project.
I do the following after connecting to my app:

bc1_0-1703245856197.png

but as you can see in the file, it will not let me execute this query - is there something I am missing?

Øystein_Kolsrud
Employee
Employee

I can't see the full request window in that screenshot, but from what I see it looks like you are trying to use JavaScript code as the request. The Engine API explorer operates directly on the JSON RPC level, so you need to follow that format.

110
Creator
Creator

I don't know if this helps - but Kabir Rab made an add-on / visualisation for Qlik that uses the API to pull these in, unfortunately, it doesn't look like he's been working on it since 2020

https://github.com/kabir-rab/master-items-viewer

It works on some apps, but not on others, and I'm not proficient enough to figure out why, but this might be a great start for someone to fork, and update-  as when it does work, I get back all the master dimension and measures, complete with formula etc.