Skip to main content

Creating dimensions

Dimensions are created from fields in the data model tables and they determine how the data in a visualization is grouped - for example total sales per country or number of products per supplier. You typically find a dimension as the slices in a pie chart or on the x-axis of a bar chart with vertical bars.

In some situations, a predefined hierarchy can help you to display data more efficiently. In Qlik Sense, you can achieve this by defining hierarchic groups of fields as drill-down dimensions. Any fields or calculated dimensions can be grouped together. See Defining drill-down dimensions for more details.


There are three different ways of specifying dimensions in the columns definition:

  • As a string
  • As a NxDimension structure
  • As a reference to a predefined dimension, a so-called master dimension
Note: The order of the columns are not always important. For a basic bar chart with one dimension and one measure, the columns can be specified in any order. But for a table it matters which order the columns are specified since the order specified in the cols parameter is the order shown in the table.

Defining dimensions using string syntax

Using the string syntax is the easiest way of defining dimensions. But there are some limitations and if you want create more advanced dimensions, you should use the object syntax instead.

[ "NetScoreName", "=Count(NetScoreName)" ]
One dimension (NetScoreName) and one measure (=Count(NetScoreName))

Defining dimensions using the object syntax

Use the object syntax if you want to set more options for your dimensions, for example if you want to set labels or limit the data-set to only display the top five values.

{ /*NxDimension structure*/ "qNullSuppression": true, "qDef": { /*NxInlineDimension structure*/ "qFieldDefs": ["NetScoreName"], "qFieldLabels": ["Net result"] } }

The NxDimension structure

When defining dimensions using the object syntax you define it as a NxDimension structure. Most settings are however done inside "qDef" which is a NxInlineDimensionDef structure.

For full details, see Engine API: NxDimension

Referencing predefined dimensions

You can use dimensions that are predefined in the app. You must know the Dimension ID, which is defined in the qLibraryID property. You must also state that it is a dimension in the qType property.

{ "qLibraryId":"eqZjE", "qType":"dimension" }

Defining drill-down dimensions

When several fields form a natural hierarchy, it can make sense to create a drill-down group. Any fields or calculated dimensions can be grouped together.

Continent, Country, State, City

When you use a drill-down group as a dimension in a chart, the chart uses the first field in the group's list of fields that has more than one possible value

In this example we group two fields: Course and HoID.

Set "qGrouping": "H" to define drill-down grouping. Since it is a grouped dimension, more than one field name is defined: "qFieldDefs": [ "Course", "HoID" ].

{ "qDef": { "qGrouping": "H", "qFieldDefs": [ "Course", "HoID" ], "qFieldLabels": [ "Course", "Hole" ] } }