Qlik Community

Ask a Question

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Our May 2021 end-to-end product release from Data Integration to Data Analytics is out! READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Qlik Sense Server - HyperCube with more than one measure

Hi all,

Newbie at creating hypercubes and am getting stuck on creating one with more than one measure.  The code below creates the hypercube with the dimension Phase and the measure SUM([lesserThenTen]) but is missing the second measure.

Any help would be greatly appreciated.

Cheers,

Joel

    app1.createCube({

       "qDimensions": [{

          "qDef": {

              "qFieldDefs": ["Phase"]

          }

       }],

       "qMeasures": [{

           "qDef": {

               "qDef": "SUM([lesserThenTen])",

               "qLabel": ""

           },

           "qDef1": {

               "qDef1": "SUM([greaterThanTen])",

               "qLabel": ""

           }

       }],

       "qInitialDataFetch": [{

           "qHeight": 20,

           "qWidth": 3

       }]

    }, function(reply){

        console.log(reply);

        var valueArray = [];

       

    });

2 Replies
reddy-s
Master II
Master II

Hi Joel Lau,

Try some thing like this.

function stock(reply, app){}
var app = qlik.openApp('7220b23e-c3d7-478c-b977-01285707b21d', config);
app.createCube({
"qInitialDataFetch": [
{
"qHeight": 50,
"qWidth": 3
}
],
"qDimensions": [
{
"qLabel": "Department",
"qLibraryId": "4150c5a4-e82d-4180-9b8b-93c73c5fb29f",
"qNullSuppression": true,
"qOtherTotalSpec": {
"qOtherMode": "OTHER_OFF",
"qSuppressOther": true,
"qOtherSortMode": "OTHER_SORT_DESCENDING",
"qOtherCounted": {
"qv": "5"
},
"qOtherLimitMode": "OTHER_GE_LIMIT"
}
}
],
"qMeasures": [
{
"qDef": {
"qDef": "sum([Stock Value])"
},
"qLabel": "sum([Stock Value])",
"qLibraryId": null,
"qSortBy": {
"qSortByState": 0,
"qSortByFrequency": 0,
"qSortByNumeric": 0,
"qSortByAscii": 1,
"qSortByLoadOrder": 0,
"qSortByExpression": 0,
"qExpression": {
"qv": " "
}
}
},
{
"qDef": {
"qDef": "count([Stock Value])"
},
"qLabel": "count([Stock Value])",
"qLibraryId": null,
"qSortBy": {
"qSortByState": 0,
"qSortByFrequency": 0,
"qSortByNumeric": 0,
"qSortByAscii": 1,
"qSortByLoadOrder": 0,
"qSortByExpression": 0,
"qExpression": {
"qv": " "
}
}
}
],
"qSuppressZero": false,
"qSuppressMissing": false,
"qMode": "S",
"qInterColumnSortOrder": [],
"qStateName": "$"

    },function(reply){

   

      console.log(reply);

     

    },stock);

Once you create a hypercube like this it should log the reply in the console like this:

reply.PNG

Thanks,

Sangram Reddy.

Not applicable
Author

Hi Sangram,

My original code was just actually missing some brackets .  But thank you for the detailed explanation and sample code.  It will be definitely be useful for reference in the future.

Thanks,

Joel