The semantic load prefix creates a special type of field that can be used in Qlik Sense to connect and manage relational data, such as tree structures, self-referencing parent-child structured data and/or data that can be described as a graph.
Note that the semantic load can function similarly to the Hierarchy and HierarchyBelongsTo prefixes. All three prefixes can be used as building blocks in effective front-end solutions for traversing relational data.
Semantic( loadstatement | selectstatement)
A semantic load expects an input that is exactly three or four fields wide with a strict definition of what each ordered field represents, as shown in the table below:
|This tag is a representation of the first of two objects between which there is a relationship.
|This tag will be used to describe the “forward” relationship between the first and second object. If the first object is a child and the second object is a parent, you can create a relationship tab that states “parent” or “parent of” as if you are following the relationship from child to parent.
|This tag is a representation of the second of two objects between which there is a relationship.
|This field is optional. This tag describes the “backward” or “inverse” relationship between the first and second object. If the first object is a child and the second object is a parent, a relationship tab could state “child” or “child of” as if you are following the relationship from parent to child. If you do not add a fourth field, then the second field tag will be used to describe the relationship in either direction. In that case, an arrow symbol is automatically added as part of the tag.
The following code is an example of the semantic prefix.
‘Parent’ AS Relationship,
NeighbouringObject AS Object,
‘Child’ AS Relationship
Unless otherwise specified, the examples in this topic use the following date format: MM/DD/YYYY. The date format is specified in the SET DateFormat statement in your data load script. The default date formatting may be different in your system, due to your regional settings and other factors. You can change the formats in the examples below to suit your requirements. Or you can change the formats in your load script to match these examples.
Default regional settings in apps are based on the regional system settings of the computer or server where Qlik Sense is installed. If the Qlik Sense server you are accessing is set to Sweden, the Data load editor will use Swedish regional settings for dates, time, and currency. These regional format settings are not related to the language displayed in the Qlik Sense user interface. Qlik Sense will be displayed in the same language as the browser you are using.
|The Hierarchy load prefix is used to divide and organize nodes in parent-child and other graph-like data structures and transform them into tables.
|The HierarchyBelongsTo load prefix is used to locate and organize the ancestors of parent-child and other graph-like data structures and transform them into tables.
Example - Creating a special field for connecting relationships using the semantic prefix
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset representing geography relation records which is loaded into a table named GeographyTree.
Each entry has an ID at the beginning of the line and a ParentID at the end of the line.
The semantic prefix which will add one special behavior field labeled, Relation.
if(ParentID='',null(),ParentID) AS ParentID
ID as ID,
'Parent' as Relation,
ParentID as ID,
'Child' as Relation
Load the data and open a sheet. Create a new table and add these fields as dimensions:
Then, create a filter pane with Relation as a dimension. Click Done editing.
Click Europe from the Geography dimension in the table and click Child from the Relation dimension in the filter pane. Note the expected result in the table:
Clicking Child again will show places that are "children" of the UK, one step further down.