Retrieving data

This section describes how to retrieve data, or fetch data, which can be done in two different ways:

  • Initial data fetch
  • Direct data fetch

Retrieval (or fetching) of data in Qlik Sense is primarily done through the use of hypercubes and list objects. As list objects can be seen as a special case of hypercubes, this text will primarily focus on hypercubes and only mention list objects where they deviate from hypercubes.

Generic objects can have hypercubes defined as part of their properties, and the Qlik Sense Engine provides a method called GetHyperCubeData that can be used to retrieve data from such entities. (The method is called GetListObjectData when working with list objects.) The first argument of this method is a path to the hypercube from which data should be fetched, and the second argument is a set of pages to retrieve.

Example: Retrieve first 10 cells of the first column of a hypercube

var first10CellsPage = new NxPage { 
  Top = 0,
  Left = 0,
  Width = 1,
  Height = 10
};
IEnumerable<NxDataPage> data = myObject.GetHyperCubeData(“/qHyperCubeDef”, new [] { 
  first10CellsPage
  });

Example: Retrieve first 10 rows of a hypercube

var first10RowsPage = new NxPage {
  Top = 0,
  Left = 0,
  Width = myObject.HyperCube.Size.Cx,
  Height = 10
};
IEnumerable<NxDataPage> data = myObject.GetHyperCubeData(“/qHyperCubeDef”, new [] { 
  first10RowsPage
  });

Example: Retrieve first and last 10 rows of a hypercube

var last10RowsPage = new NxPage {
  Top = myObject.HyperCube.Size.Cy - 10,
  Left = 0,
  Width = first10RowsPage.Width,
  Height = 10
};
IEnumerable<NxDataPage> data = myObject.GetHyperCubeData(“/qHyperCubeDef”, new [] {
  first10RowsPage,
  last10RowsPage
  });

Direct data fetching in hypercubes

Hypercubes support the following additional methods for retrieving data:

  • GetHyperCubeReducedData

  • GetHyperCubePivotData

  • GetHyperCubeStackData

Any of the above data fetch methods can also fetch multiple pages simultaneously. Please refer to the documentation for the individual methods for more information concerning how these methods deviate from the method GetHyperCubeData.

Initial data fetch

As clients displaying visualization objects often want to have immediate access to data from those objects, Qlik Sense provides the option of defining the property InitialDataFetch for hypercubes. Use of InitialDataFetch will have the effect that data will be included directly as part of the layout of the hypercube. This means that the first set of data can be read directly from the layout of the generic object containing the hypercube without having to go through an additional call to the method GetHyperCubeData.

Note: This data is part of the generic object and will therefore cause data to be calculated when accessing unrelated parts of an invalidated generic object.

Example: Retrieve first 10 cells of the first column of a hypercube using initial data fetch

  using (myObject.SuspendedLayout)
  {
    myObject.Properties.HyperCubeDef.InitialDataFetch = new [] { first10CellsPage };
  }
  IEnumerable&lt;NxDataPage&gt; data = myObject.HyperCube.DataPages;

Did this information help you?

Thanks for letting us know. Is there anything you'd like to tell us about this topic?

Can you tell us why it did not help you and how we can improve it?