Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Showing results for 
Search instead for 
Did you mean: 

Dynamically add dimensions to Hypercube


I have a requirement for user to be able to add a number of dimensions to a table in one step, without editing the extension and having to add the one by one. There is also a requirement that the data be exportable.

I was able to get the list of fields by calling app.getList("DimensionList" ..), passing the dimensions  to createCube(), and rendering the resulting Hypercube to a table. This approach works, but the data is not available for export from the export context menu. I think I need to do one of the following:

  1. Find a way to get the export function to point at the Hypercube that was created with createCube() so users can download an Excel workbook.
  2. Modify the extension's Hypercube that is defined in its initialProperties at runtime to include new dimensions.

Is number one even possible?

Number two seems like the correct option. Is using applyPatches() with operation "add" the right way to do it? Assuming it is, I have the following questions:

  1. Does the entire structure of the elements in qHyperCubeDef.qDimensions have to be given, or can I just set the dimension name?
  2. Can I just set the dimension's qId to any random value, or does this value have to be looked up someplace?
  3. Is qHyperCubeDef.qInterColumnSortOrder always just a list from 0 to N? Does it have to be explicitly set?

Any pointers in the right direction would be greatly appreciated.


Labels (1)
4 Replies

Re: Dynamically add dimensions to Hypercube


Yes, applyPatches() is the right call to use for this. I once wrote a short guide to it, you find it here:


If you are using dimensions (which is what you get from DimensionList), the key property that needs to be set is qLibraryId.  I think everything else is optional. You find the complete structure here:


qInterColumnSortOrder is an array that determines in which order columns are used for sorting. Start with not setting it, that will give you the default, which is 0,1,2....


Hope this helps


Re: Dynamically add dimensions to Hypercube

Thank you for your reply, Erik.

Unfortunately I misspoke earlier when I said I was using getList( "DimensionList" ). This call returns an empty array. I was actually calling getList( "FieldList" ). It returns all the dimensions in the data source, but the objects do not contain the unique ID for the dimensions.

I tried creating  a generic object of type qDimensionListDef, but it returned an empty list. I also tried defining the qDimensionListDef in the initial properties, but it too was an empty list.

I should add the Hypercube is populated with data and appears to work as expected.

Is there some other way to get the dimension IDs?






Re: Dynamically add dimensions to Hypercube

Are there dimensions defined in the app? If getList("DimensionList") returns an empty array there might not be any.

To use qDimensionListDef you also need to set qType to 'dimension'. For an example, check here:


If there are no dimensions defined, you need to use the FieldList instead (or define dimensions..).


Re: Dynamically add dimensions to Hypercube

What I ended up doing was create a hypercube with the list of fields as dimension, and then stashing the context returned in the promise into a variable. Subsequent data fetches use this context instead of the on in the main app to get data.