Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
marcelinoa
Partner - Contributor III
Partner - Contributor III

How to get correct Master Item description in Qlik Sense

Hi,  I'm making some modifications to the extension show-hide so that I can have a Details Button that shows the Description of the Master Items used in the visualization. The folowing code is working but I have yet to find a way to match a dimension/measure to it's corresponding description since I have to make distinct call to get the info I need.

 

app.getList("DimensionList", function(reply){
    metadata.DimensionsDetails = reply.qDimensionList.qItems.map(function(o){
        return o.qMeta.description;
    })
});

app.getList("MeasureList", function(reply){
    metadata.MeasuresDetails = reply.qMeasureList.qItems.map(function(o){
        return o.qMeta.description;
    })
});

app.getObject(objectId).then(function(model){
    if(model.layout.qHyperCube == undefined) {
        deferred.resolve();
    } else {
        metadata.Visualization = model.layout.qMeta.description;

        model.layout.qHyperCube.qDimensionInfo.forEach(function(item, index){
            arrayOne[index] = item.title;
        })

        metadata.Dimensions = model.layout.qHyperCube.qDimensionInfo.map(function(o){
            return o.qFallbackTitle == null || o.qFallbackTitle.length <= 1 ?
                o.qGroupFieldDefs[0] : o.qFallbackTitle;
            });

        metadata.Measures = model.layout.qHyperCube.qMeasureInfo.map(function(o){
            return o.qFallbackTitle == null || o.qFallbackTitle.length <= 1 ?
                o.qAttrExprInfo[0].qFallbackTitle : o.qFallbackTitle;
            });

        deferred.resolve(metadata);
    }
});
return deferred.promise;

Any help would be appreciated.

 

 

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

Looking at the API I realize that you could probably use getObjectProperties() instead. That would give you the properties structure, and you can look in qHyperCubeDef and find the id's.

View solution in original post

7 Replies
marcelinoa
Partner - Contributor III
Partner - Contributor III
Author

I was able to match the DImensions using the property title  found in the method getList("DimensionsList") and in getObject(objectId) but with the Measures it's a different story.

With getObject(objectId) I can only get the qFallbackTitle of the Measure and with getList("MeasureList") I only get a title (besides de much needed description), but if I use the createGenericObject like so:

app.createGenericObject({
    qInfo: {
        qType: "MeasureList"
    },
    qMeasureListDef: {
        qType: "measure",
        qData: {
            qMeasure: "/qMeasure"
        }
    }
}

I can get the the qLabelExpression that is almost the qFallbackTitle I want to make a match but not quite since it's not calculated.

 

I would really appreciate any help I could get.

ErikWetterberg

Hi,

best way is probably to call getProperties on your object and use the qLibraryId field to find the correct dimension or measure.

.

marcelinoa
Partner - Contributor III
Partner - Contributor III
Author

Thank you for the reply Erik.

Any idea how you would implement what you said?

The snippet of code I pasted is from an angular service and all the code is in an angular controller, if that changes anything, I'm only stating it because I'm more familiar with just doing everything inside the paint method with regular javaScripit but decided to learn how to do it with AngularJS and it is a bit different, mainly when it comes to the backendApi from which I should call the getProperties method correct?

 

ErikWetterberg

Hi,

Looking at the API I realize that you could probably use getObjectProperties() instead. That would give you the properties structure, and you can look in qHyperCubeDef and find the id's.

marcelinoa
Partner - Contributor III
Partner - Contributor III
Author

Thank you for your help, by using the getObjectProperties() I was able to get the Measures Id and match with that!

marcelinoa
Partner - Contributor III
Partner - Contributor III
Author

A little bit related but also a bit different and was hoping you could help. Just realized the following, I want to get the description of said Measure/Dimension and can do so with getList(), but I didn't realize until now that it only returns the normal description and I might need the descriptionExpression if an expression is used.

I'm using the following createGenericObject and I can get the Measure descriptionExpression just fine but can't do the same with the Dimension. I reckon there's something wrong with the way I'm calling but I can't seem to see what.

 

app.createGenericObject({
    qMeasureListDef : {
        qType: "measure", 
        qData: { 
            measure: "/qMeasure"
        }
    },
    qDimensionListDef : {
        qType: "dimension", 
        qData: { 
            dimension: "/qDimension"
        }
    }
}
marcelinoa
Partner - Contributor III
Partner - Contributor III
Author

Found the answer here on a previous post of yours. Guess you still helped me anyway 🙂