Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear Community,
I am interested in retrieving the information about which master measure is used in which visualization object (table, KPI, barchart etc.). I am looking for a method to apply in the Engine API. Otherwise I could also use the QRS of course, just don't know where to find this information.
Would be great if I could get some help on this. I have been searching for a while now, but nothing useful came up.
Best,
Mira
Hello,
You need to get the layout of the current sheet. Loop through each object and get their layout to find their measures. Each measure that has a "qLibraryId" is a master measure.
Here's an idea of the flow using capability api, within an extension context:
define( [ "qlik"
],
function ( qlik) {
var app = qlik.currApp();
var chartsAndMeasuresOnSheet = [];
return {
support : {
snapshot: true,
export: true,
exportData : false
},
paint: function ($element) {
//add your rendering code here
$element.html( "checkForMasterItemsOnSheet" );
var sheetId = qlik.navigation.getCurrentSheetId().sheetId;
app.getObject(sheetId)
.then((sheetObject) => {
return sheetObject.getLayout()
.then((sheetLayout) => {
console.log({sheetLayout});
(sheetLayout.cells).forEach(function (object) {
var objectId = object.name;
app.getObject(objectId).then((viz) => {
var chartType = viz.genericType;
var chartId = viz.id;
var chartMeasures = viz.layout.qHyperCube.qMeasureInfo;
var chartMasterMeasures = chartMeasures.filter(function (el) { // only keep the master measures
return el.qLibraryId;
});
chartsAndMeasuresOnSheet.push({id: chartId, type: chartType, masterMeasures: chartMasterMeasures});
})
})
})
})
// you might need to deal with promise chaining, but that's the idea and it works within the context of an extension
console.log({chartsAndMeasuresOnSheet});
}
};
} );