The First prefix to a LOAD or SELECT (SQL) statement is used for loading a set maximum number of records from a data source table. A typical use case for using the First prefix is when you want to retrieve a small subset of records from a large and/or slow data load step. As soon as the defined “n” number of records has been loaded, the load step terminates prematurely, and the rest of the script execution continues as normal.
First n ( loadstatement | selectstatement )
|An arbitrary expression that evaluates to an integer indicating the maximum number of records to be read. n can also be enclosed in parentheses: (n).
|loadstatement | selectstatement
|The load statement/select statement that follows the n argument will define the specified table that must be loaded with the set maximum number of records.
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. For more information, see Modifying regional settings for apps and scripts.
Default regional settings in apps are based on the user profile. These regional format settings are not related to the language displayed in the Qlik Cloud user interface. Qlik Cloud will be displayed in the same language as the browser you are using.
If you are an app creator, you can set the default region for apps you create. For more information, see Setting your preferred regional settings for creating apps and scripts in Qlik Cloud Analytics.
|FIRST 10 LOAD * from abc.csv;
|This example will retrieve the first ten lines from an excel file.
|FIRST (1) SQL SELECT * from Orders;
|This example will retrieve the first selected line from the Orders dataset.
Example – Load the first five rows
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset of dates from the first two weeks of 2020.
The First variable that instructs the application to only load the first five records.
The script only loads the first five records of the Sales table.