Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do you get a measures expression from Hypercube? and is it possible to change it?

Hi,

I'm new to extension and Javascript in general. Have started poking around and experimenting with extensions.

I am wondering if it's possible to retrieve the expression of a measure and change it.

And if it's possible how, where and when should you do it.

Best regards

Karl

15 Replies
Not applicable
Author

Aha, but there is no specific notification for changes in properties?

So I need to cache my properties and check if they have changed since last time paint was invoked.

Not applicable
Author

That is correct. Perhaps something that will be adressed in a later version.

Not applicable
Author

Thanks for the references.

qMeasureInfo doesn't include the qDef with the expression as far as I can see. Maybe it should be added in a future release.

Regarding the Mashup API, for a beginner the name of the API is confusing. I thought it where only to be used when creating Mashups. But it's not, right?

I am experimenting with an extension and I want to create 2 new measures based of the measure from the layouts hypercube with some additional set analsysis added. Is it best practise to create another hypercube with the new measures using app.createCube()?

ErikWetterberg

Hi Carl,

No you should in most cases not use createCube etc in your extension, they are designed for the pure mashup case, with a web page that connects to Qlik Sense. In an extension you define your hypercube in initialproperties instead.

We are not ready with an API to do this, but you could probably make a partial solution in paint. You would then need to check how many measures are defined and if your extra measures are not there add them. Something like this:

paint : function($element, layout) {

if(this.backendApi.getMeasureInfos().length === 1){

     //only do this if there is only one measure

     var me = this;

     this.backendApi.getProperties().then(function(reply){

          reply.qHyperCubeDef.qMeasures.push({......}); //add measure

          me.backendApi.setProperties(reply);

     });

     //probably dont want to paint with just one measure

     return;

}

//painting with no or several measures

}

But there are some problems with this...The user might not have update rights to the visualization. Also if the user modifies the measure it will probably not work.

Not applicable
Author

I get it, and I should probaly work on the visualisation part of my extension instead until the API is more fleshed out.

Do you have a roadmap for the public?

Alot of companies I have seen share their roadmaps on Trello. A great way for the community to see what's coming and a rough when.

Not applicable
Author

I made some digging around and found that you can use change and globalChange in properties that seems to works as I want.

change : function(data) {

                                    updateStuff(data);

                                    return true;

                                },

Can you explain what's the difference between change and globalChange?