Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I've Qlik sense Cloud. I created a custom extension in the Dev Hub through extension creator to create a variable which gets its value from a formula. Custom extension is also visible in the custom objects under extension tab.
define([], function() {
'use strict';
return {
paint: function($element, layout) {
var app = qlik.currApp();
app.createCube({
qDimensions: [],
qMeasures: [{
qDef: {
qDef: "=Sum({<Year={'2023'}, Scenario ={'Forecast'}, Data_type ={'Costs'}>}(Amount/1000))",
qLabel: "TotalHQDC"
}
}],
qInitialDataFetch: [{
qTop: 0,
qLeft: 0,
qHeight: 1,
qWidth: 1
}]
}, function(reply) {
var totalHQDC = reply.qHyperCube.qDataPages[0].qMatrix[0][0].qNum;
app.variable.setStringValue('vTotalHQDC', totalHQDC.toString());
});
}
};
});
in the load editor, I have added following code
LET vTotalHQDCExtension = if(isnull($(vTotalHQDC)), 'TotalHQDC', $(vTotalHQDC));
LET vTotalHQDC = Num($(#=app.variable.get("TotalHQDC").value));
it basically check if the variable vTotalHQDC
is null or not, and if it is null then set the vTotalHQDCExtension
variable to "TotalHQDC". The second LET statement then converts the value of the TotalHQDC
variable to a number using the Num
function.
then I added a text in a sheet and added fx = $(vTotalHQDC
)
I am getting no error but value is coming as zero in the text. even if I used KPI object then value returns as 0. so not sure where I'm going wrong. is it something to do with my limited access in Qlik cloud or there is flaw in this entire approach?