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
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.
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.
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
Refers to a dimension stored in the library.
The definition of the dimension.
For full details, see Engine API: NxInlineDimension
If set to true, no null values are returned.
Sets the dimension limits. Each dimension of a hypercube is configured separately.
Defines if some values (grouped as Others) should be grouped together in the visualization.
If set to true, all dimension values are shown.
This property is used when dimension limits have been set in qOtherTotalSpec.
Defines the label of the Others group. The default label is Others.
This property is used when total mode have been set in qOtherTotalSpec.
Defines the label of the Totals group.
Specifies a calculation condition, which must be fulfilled for the dimension to be calculated.
If the calculation condition is not met, the dimension is excluded from the calculation.
List of attribute expressions.
List of attribute dimensions.
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.
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" ].