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: 
briwilli
Contributor III
Contributor III

Dynamically format a numeric value in a mashup displaying pivot table

I have a Qlik Sense mashup that displays a pivot table.  We would like our users to be able to toggle the data so that they can view the detail rows as percentages while the totals row still displays the aggregate counts.  Is there a way to do this within the mashup javascript code?   I know I can do this by modifying the measure definition within the qvf file but we have many apps with multiple measures, so I would like to put this logic in the javascript code.  I was hoping to use the qNumFormat structure with an expression as shown below but this does not work.  Does anyone know if numeric formating can be done using the Qlik Sense mashup APIs?  

$scope.chkTogglePercentage = function () {

app.getObject($scope.pivotObjId).then(function (obj) {

obj.getProperties().then(function(props) {

props.qHyperCubeDef.qMeasures.forEach(function (qMeasure, index) {

var numFormat = {

"qType": "F",

"qnDec": 2,

"qUseThou": 0,

"qThou": ",",

"qDec":".",

"qFmt": "if(dimensionality()=0,'#,##0','#.##%')"

};

qMeasure.qDef.qNumFormat = numFormat;

});

obj.setProperties(props);

});

});

};

0 Replies