# Load

The LOAD statement loads fields from a file, from data defined in the script, from a previously loaded table, from a web page, from the result of a subsequent SELECT statement or by generating data automatically.

Syntax:

LOAD [ distinct ] fieldlist

[( from file [ format-spec ] |

from\_field fieldassource [format-spec]

inline data [ format-spec ] |

*resident* table-label |

autogenerate size )]

[ where criterion | while criterion ]

[ group\_by groupbyfieldlist ]

[order\_by orderbyfieldlist ]

Arguments:

Load arguments

| Argument | Description |
| --- | --- |
| distinct[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm) | You can use distinct as a predicate if you only want to load<br>unique records. If there are duplicate records, the first instance will be loaded.<br><br>If you are using preceding loads, you need to place distinct in the first load statement, as distinct only affects the destination table. |
| fieldlist | fieldlist ::= ( \* \| field {, field } )<br><br>A list of the fields to be loaded. Using \* as a field list indicates<br>all fields in the table.<br><br>field ::= ( fieldref \| expression ) [as aliasname ]<br><br>The field definition must always contain<br>a literal, a reference to an existing field, or an expression.<br><br>fieldref ::= ( fieldname \|@fieldnumber<br>\|@startpos:endpos<br>[ I \| U \| R \| B \| T] )<br><br>fieldname is a text that is<br>identical to a field name in the table. Note that the field name must<br>be enclosed by straight double quotation marks or square brackets if it contains e.g. spaces.<br>Sometimes field names are not explicitly available. Then a different notation<br>is used:<br><br><br>@fieldnumber represents the<br>field number in a delimited table file. It must be a positive integer<br>preceded by "@". The numbering is always made from 1 and up<br>to the number of fields.<br><br><br>@startpos:endpos<br>represents the start and end positions of a field in a file with fixed<br>length records. The positions must both be positive integers. The two<br>numbers must be preceded by "@" and separated by a colon. The<br>numbering is always made from 1 and up to the number of positions. In the last field, n is used as end position.<br><br><ul> <li>If  <span>@<span>startpos</span>:<span>endpos</span></span>  is immediately followed by the characters <span>I</span> or  <span>U</span>, the bytes read will be interpreted as a binary  signed (<span>I</span>) or unsigned (<span>U</span>)  integer (Intel byte order). The number of positions read must be 1, 2  or 4. </li> <li>If <span>@<span>startpos</span>:<span>endpos</span></span> is  immediately followed by the character <span>R</span>, the bytes  read will be interpreted as a binary real number (IEEE 32-bit or 64 bit  floating point). The number of positions read must be 4 or 8. </li> <li>If <span>@<span>startpos</span>:<span>endpos</span></span> is immediately followed  by the character <span>B</span>, the bytes read will be interpreted  as a <span>BCD (Binary Coded Decimal)</span> numbers according to the COMP-3 standard.  Any number of bytes may be specified. </li> </ul><br><br>expression can be a numeric<br>function or a string function based on one or several other fields in<br>the same table. For further information, see the syntax of expressions.<br><br>[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)as is used for assigning a new<br>name to the field. |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>from | from is used if data should<br>be loaded from a file.<br><br>file ::= [ path ] filename<br><br><ul> <li> <p> absolute </p> <p><span><span>Example: </span></span><span>c:\data\</span> </p> </li> <li> <p>relative to the <span>QlikView</span> document path.</p> <p><span><span>Example: </span></span><span>data\</span> </p> </li> <li> <p>URL address (<span>HTTP</span>  or <span>FTP</span>), pointing to a location on the Internet or an intranet. The URL must be URL encoded, for example, if it contains space characters.</p> <p><span><span>Example: </span></span><span>http://www.qlik.com</span> </p> <p><span><span>Example: </span></span><span>http://www.enterprise.com/project%20files</span> (<span>http://www.enterprise.com/project files</span>)</p> </li> </ul><br><br>If the path<br>is omitted, QlikView searches for the file in the directory specified<br>by the Directory statement. If there is no Directory statement, QlikView searches in the working directory, which is usually the directory in which the QlikView file is located.<br><br>Information noteIn a QlikView server installation, the default working directory is C:\ProgramData\QlikTech\Documents. The default working directory can be modified in the QlikView Management Console.<br><br>The filename<br>may contain the standard DOS wildcard characters ( \* and ? ). This will<br>cause all the matching files in the specified directory to be loaded.<br><br>format-spec ::= ( fspec-item { , fspec-item<br>} )<br><br>The format specification consists of a list<br>of several format specification items, within brackets.<br><br>[Directory](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Directory.htm)<br><br>[From](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/From.htm) |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>from\_field | from\_field<br>is used if data should be loaded from a previously loaded field.<br><br>fieldassource::=(tablename, fieldname)<br><br>The field is the name of the previously loaded<br>tablename and fieldname.<br><br>format-spec ::= ( fspec-item<br>{, fspec-item } )<br><br>The format specification consists of a list<br>of several format specification items, within brackets. |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>inline | inline is used if data should<br>be typed within the script, and not loaded from a file.<br><br>data ::= [ text ]<br><br>Data entered through an inline<br>clause must be enclosed by specific characters – square brackets, quotation marks, or back ticks. The text between these is interpreted in the<br>same way as the content of a file. Hence, where you would insert a new<br>line in a text file, you should also do it in the text of an inline clause: by pressing the Enter key when typing the script.<br><br>In a simple inline load, the number of columns are defined by the first line.<br><br>format-spec ::= ( fspec-item<br>{, fspec-item } )<br><br>You can customize the inline load with many of the same format specification items that are available for other loaded tables. These items are listed in brackets. For more information, see [Format specification items](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptSpecifiers/format-specification-items.htm).<br><br>For more information about inline loads, see [Loading data from inline tables](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/inline-loads-qv.htm). |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>resident | resident is used if data<br>should be loaded from a previously loaded table.<br><br>table label is a label preceding<br>the LOAD or SELECT statement(s)<br>that created the original table. The label should be given with<br>a colon at the end.<br><br>When using a combination of distinct and resident load statements in QlikView 12.00 or later, the data load order is different from QlikView 11.20. To define a desired load order, add a order by clause.<br><br>[Loading data from a previously loaded table](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/load-data-from-previously-loaded-table.htm)<br><br>[Table labels](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/table-labels.htm) |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>autogenerate | autogenerate is used<br>if data should be automatically generated by QlikView.<br><br>size ::= number<br><br>Number<br>is an integer indicating the number of records to be generated. The field list<br>must not contain expressions which require data from a database. Only<br>constants and parameter-free functions (such as rand() or recno()), are allowed in the expressions. |
| extension | You can load data from analytic connections. You need to use the extension clause to call a function defined in the server-side extension (SSE) plugin, or evaluate a script.<br><br>You can send a single table to the SSE plugin, and a single data table is returned. If the plugin does not specify the names of the fields that are returned, the fields will be named Field1, Field2, and so on.<br><br>Extension pluginname.functionname( tabledescription );<br><br><ul> <li> <p>Loading data using a function in an SSE plugin </p> <p><span>tabledescription ::= (table { ,tablefield} )</span> </p> <p>If you do not state table fields, the fields will be used in load order.</p> </li> <li> <p>Loading data by evaluating a script in an SSE plugin</p> <p><span>tabledescription ::= ( script, table { ,tablefield} )</span> </p> </li> </ul><br><br>Data type handling in the table field definition<br><br>Data types are automatically detected in analytic connections. If the data has no numeric values and at least one non-NULL text string, the field is considered as text. In any other case it is considered as numeric.<br><br>You can force the data type by wrapping a field name with String() or Mixed().<br><br><ul> <li><span>String()</span> forces the field to be text. If the field is numeric, the text part of the dual value is extracted, there is no conversion performed.</li> <li><span>Mixed()</span> forces the field to be dual.</li> </ul><br><br>String() or Mixed() cannot be used outside extension table field definitions, and you cannot use other QlikView functions in a table field definition.<br><br>More about analytic connections<br><br>For creating an analytic connection in QlikView Server or QlikView Desktop, see: [Analytic connections](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Analytic_connections.htm)<br><br>You can read more about analytic connections in the GitHub repository. [qlik-oss/server-side-extension](https://github.com/qlik-oss/server-side-extension) |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>where | where is a clause used for<br>stating whether a record should be included in the selection or not. The<br>selection is included if criterion<br>is True.<br><br>criterion is a logical expression. |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>while | while is a clause used for<br>stating whether a record should be repeatedly read. The same record is<br>read as long as criterion is<br>True. In order to be useful, a while clause must<br>typically include the IterNo( ) function.<br><br>criterion is a logical expression. |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>group\_by | group by is a clause used<br>for defining over which fields the data should be aggregated (grouped).<br>The aggregation fields should be included in some way in the expressions<br>loaded. No other fields than the aggregation fields may be used outside<br>aggregation functions in the loaded expressions.<br><br>groupbyfieldlist ::= (fieldname { ,fieldname } ) |
| [](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)<br>order\_by | order by<br>is a clause used for sorting the records of a resident table before<br>they are processed by the load statement. The<br>resident table can be sorted by one or more fields in ascending or descending<br>order. The sorting is made primarily by numeric value and secondarily<br>by national collation order. This clause may only be used when the data source<br>is a resident table.<br><br>The ordering fields specify which field<br>the resident table is sorted by. The field can be specified by its name<br>or by its number in the resident table (the first field is number 1).<br><br>orderbyfieldlist ::= fieldname [ sortorder ] { , fieldname [ sortorder ] }<br><br>sortorder is either asc for ascending or desc for descending. If no<br>sortorder is specified, asc is assumed.<br><br>fieldname, path, filename and aliasname are text strings representing what the respective names imply. Any field in the source table can be used as fieldname. However, fields created through the as clause (aliasname) are out of scope and cannot be used inside the same load statement. |

If no source of data is given by means of a from, inline, resident, from\_field or autogenerate clause, data will be loaded from the result of the immediately succeeding SELECT or LOAD statement. The succeeding statement should not have a prefix.

[Preceding LOAD](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/preceding-load.htm)

Examples:

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading different file formats

Load a delimited data file with default options:

`LOAD * from data1.csv;
` ` `

Load a delimited file, specifying comma as delimiter and with embedded labels:

`LOAD * from 'c:\userfiles\data1.csv' (ansi, 
 txt, delimiter is ',', embedded labels);
` ` `

Load a delimited file specifying tab as delimiter and with embedded labels:

`LOAD * from 'c:\userfiles\data2.txt' (ansi, 
 txt, delimiter is '\t', embedded labels);` ` `

Load a dif file with embedded headers:

`LOAD * from file2.dif (ansi, dif, embedded 
 labels);` ` `

Load three fields from a fixed record file without headers:

`LOAD @1:2 as ID, @3:25 as Name, @57:80 as City 
 from data4.fix (ansi, fix, no labels, header is 0, record is 80);
` ` `

Load a QVX file, specifying an absolute path:

`LOAD * from C:\qdssamples\xyz.qvx (qvx);` ` `

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Selecting certain fields, renaming and calculating fields

Load only three specific fields from a delimited file:

`LOAD FirstName, LastName, Number from data1.csv;
` ` `

Rename first field as A and second field as B when loading a file without labels:

`LOAD @1 as A, @2 as B from data3.txt (ansi, 
 txt, delimiter is '\t', no labels);
` ` `

Load Name as a concatenation of FirstName, a space character, and LastName:

`LOAD FirstName&' '&LastName as Name 
 from data1.csv;
` ` `

Load Quantity, Price and Value (the product of Quantity and Price):

`LOAD Quantity, Price, Quantity*Price as Value 
 from data1.csv;`

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Selecting certain records

Load only unique records, duplicate records will be discarded:

`LOAD distinct FirstName, LastName, Number from 
 data1.csv;
` ` `

Load only records where the field Litres has a value above zero:

`LOAD * from Consumption.csv where Litres>0;
`

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading data not on file and auto-generated data

Load a table with inline data, two fields named CatID and Category:

` LOAD * Inline
         ` ` [CatID, Category
         ` ` 0,Regular
         ` ` 1,Occasional
         ` ` 2,Permanent];
         ` ` `

Load a table with inline data, three fields named UserID, Password and Access:

` LOAD * Inline [UserID, Password, Access
         ` ` A, ABC456, User
         ` ` B, VIP789, Admin];
         ` ` `

Load a table with 10 000 rows. Field A will contain the number of the read record (1,2,3,4,5...) and field B will contain a random number between 0 and 1:

`LOAD RecNo( ) as A, rand( ) as B autogenerate(10000);`

Information noteThe parenthesis after autogenerate is allowed but not required.

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading data from a previously loaded table

First we load a delimited table file and name it tab1:

` tab1:
         ` `SELECT A,B,C,D from transtable;
` ` `

Load fields from the already loaded tab1 table as tab2:

`tab2:` `LOAD A,B,month(C),A*B+D as E resident tab1;` ` `

Load fields from already loaded table tab1 but only records where A is larger than B:

`tab3:` `LOAD A,A+B+C resident tab1 where A>B;` ` `

Load fields from already loaded table tab1 ordered by A:

`LOAD A,B*C as E resident tab1 order by A;` ` `

Load fields from already loaded table tab1, ordered by the first field, then the second field:

`LOAD A,B*C as E resident tab1 order by 1,2;` ` `

Load fields from already loaded table tab1 ordered by C descending, then B in ascending order, and then the first field in descending order:

`LOAD A,B*C as E resident 
 tab1 order by C desc, B asc, 1 des;`

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading data from previously loaded fields

Load field Types from previously loaded table Characters as A:

`LOAD A from_field (Characters, 
 Types);`

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading data from a succeeding table (preceding load)

Load A, B and calculated fields X and Y from Table1 that is loaded in succeeding SELECT statement:

` LOAD A, B, if(C>0,'positive','negative') 
 as X, weekday(D) as Y;
         ` `SELECT A,B,C,D from Table1;` ` `

[Preceding LOAD](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/preceding-load.htm)

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Grouping data

Load fields grouped (aggregated) by ArtNo:

`LOAD ArtNo, round(Sum(TransAmount),0.05) as 
 ArtNoTotal from table.csv group by ArtNo;
` ` `

Load fields grouped (aggregated) by Week and ArtNo:

`LOAD Week, ArtNo, round(Avg(TransAmount),0.05) 
 as WeekArtNoAverages from table.csv group by Week, ArtNo;` ` `

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Reading one record repeatedly

In this example we have a input file Grades.csv containing the grades for each student condensed in one field:

`Student,Grades` `Mike,5234` `John,3345` `Pete,1234` `Paul,3352`

The grades, in a 1-5 scale, represent subjects Math, English, Science and History. We can separate the grades into separate values by reading each record several times with a while clause, using the IterNo( ) function as a counter. In each read, the grade is extracted with the Mid function and stored in Grade, and the subject is selected using the pick function and stored in Subject. The final while clause contains the test to check if all grades have been read (four per student in this case), which means next student record should be read.

` MyTab:
         ` ` LOAD 
 Student,
         ` ` mid(Grades,IterNo( 
 ),1) as Grade,
         ` ` pick(IterNo( 
 ), 'Math', 'English', 'Science', 'History') as Subject from Grades.csv
         ` `while IsNum(mid(Grades,IterNo(),1));` ` `

The result is a table containing this data:

![A table containing data for Students, Subjects, and Grades.](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/Resources/Images/ex_gen_LoadRepeated.png)

[](https://help.qlik.com/en-US/qlikview/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptRegularStatements/Load.htm)

#### Loading from analytic connections

The following sample data is used.

```
Values:
Load
 Rand() as A,
 Rand() as B,
 Rand() as C
AutoGenerate(50);
```

Loading data using a function

In these examples, we assume that we have an analytic connection plugin named P that contains a custom function Calculate(Parameter1, Parameter2). The function returns the table Results that contains the fields Field1 and Field2.

```
Load * Extension P.Calculate( Values{A, C} );
```

Load all fields that are returned when sending the fields A and C to the function.

```
Load Field1 Extension P.Calculate( Values{A, C} );
```

Load only the Field1 field when sending the fields A and C to the function.

```
Load * Extension P.Calculate( Values );
```

Load all fields that are returned when sending the fields A and B to the function. As fields are not specified, A and B are used as they are the first in order in the table.

```
Load * Extension P.Calculate( Values {C, C});
```

Load all fields that are returned when sending the field C to both parameters of the function.

Load \* Extension P.Calculate( Values {String(A), Mixed(B)});

Load all fields that are returned when sending the field A forced as a string and B forced as a numeric to the function.

Loading data by evaluating a script

Load A as A\_echo, B as B\_echo Extension R.ScriptEval( 'q;', Values{A, B} );

Load the table returned by the script q when sending the values of A and B.

Load \* Extension R.ScriptEval( '$(My\_R\_Script)', Values{A, B} );

Load the table returned by the script stored in the My\_R\_Script variable when sending the values of A and B.

Load \* Extension R.ScriptEval( '$(My\_R\_Script)', Values{B as D, \*} );

Load the table returned by the script stored in the My\_R\_Script variable when sending the values of B renamed to D, A and C. Using \* sends the remaining unreferenced fields.

## Learn more

* [Format specification items](https://help.qlik.com/en-US/qlikview/September2026/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptSpecifiers/format-specification-items.htm)