0 Replies Latest reply: Aug 25, 2017 9:33 AM by Marco Hamacher RSS

    How to retrieve multiple data pages from generic Cube?

    Marco Hamacher

      Hi everyone,

       

      again I am struggeling to access qliks' data via js.

      I created a cube to fetch data from the qlik app but I need to fetch multiple pages of data and getHyperCubeData() or getData() do not seem to work.

      To now my code is the following:

       

      app.createCube({

                      qDimensions: dimensionDefinition,

                      qInitialDataFetch: [{

                          qTop: 0,

                          qLeft: 0,

                          qHeight: necessaryHeight,

                          qWidth: usedFields.length

                      }]

                  }, function(reply) {

                      var allSelections = [];

                      for(var i = 0; i < usedFields.length; i++){

                        allSelections.push([]);

                      }

                      _.each(reply.qHyperCube.qDataPages[0].qMatrix,function(value){

                        for(var i = 0; i < usedFields.length; i++){

                          allSelections[i].push(value[i]);

                        }

                      });

                      for(var i = 0; i < usedFields.length; i++){

                        allSelections[i] = _.uniq(_.pluck(allSelections[i],"qText"));

                      }

      // Somewhere here I would need to conduct additional data requests as necessaryHeight * usedFields.length will exceed 10000 cells

       

                      console.log(allSelections);

                      app.destroySessionObject(reply.qInfo.qId);

                  });

       

      This gives me an array of arrays with all explicitly applied selections per field.

      However, as I learned earlier (props to erik.wetterberg) the qMatrix returns the cartesian product of all values which inflates this data request heavily.

       

      Therefore I either need to request additional data pages in the callback or find a way to avoid this inflated request.

      (I tried lists, which are more convenient, but I would have to retrieve a list for every field in which a filter has been set. That gave me a headache in structuring my code as the promises resolve before I could log the lists data.)

       

      Any idea on this is much appreciated, as well as other takes on how to get all selected values for all fields from the qlik engine.

       

      Kind regards,

      Marco