These functions are used when a value from previously loaded records of data is needed for the evaluation of the current record.
exists(field [ , expression ] )
Determines whether a specific field value exists in a specified field of the data loaded so far. Field is a name or a string expression evaluating to a field name. The field must exist in the data loaded so far by the script. Expr is an expression evaluating to the field value to look for in the specified field. If omitted, the current record’s value in the specified field will be assumed.
exists(Month, 'Jan') returns -1 (true) if the field value 'Jan' is found in the current content of the field Month.
exists(IDnr, IDnr) returns -1 (true) if the value of the field IDnr in the current record already exists in any previously read record containing that field.
exists (IDnr) is identical to the previous example.
Load Employee, ID, Salary from Employees.csv; Load FirstName& ' ' &LastName as Employee, Comment from Citizens.csv where exists (Employee, FirstName& ' ' &LastName); Only comments regarding those citizens who are employees are read.
Load A, B, C, from Employees.csv where not exists (A); This is equivalent to performing a distinct load on field A.
Returns the value of expression using data from the previous input record that was not discarded due to a where clause. In the first record of an internal table the function will return NULL. The previous function may be nested in order to access records further back. Data are fetched directly from the input source, making it possible to refer also to fields which have not been loaded into QlikView, i.e. even if they have not been stored in its associative database.
Load *, Sales / previous(Sales) as Increase from ...;
Load A, previous(previous( A )) as B from ...;
peek(fieldname [ , row [ , tablename ] ] )
Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.
Fieldname must be given as a string (e.g. a quoted literal).
Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.
If no row is stated, -1 is assumed.
Tablename is a table label, see Table Labels, without the ending colon. If no tablename is stated, the current table is assumed. If used outside the load statement or referring to another table, the tablename must be included.
peek( 'Sales' ) returns the value of Sales in the previous record read ( equivalent to previous(Sales) ).
peek( 'Sales', 2 ) returns the value of Sales from the third record read from the current internal table.
peek( 'Sales', -2 ) returns the value of Sales from the second last record read into the current internal table.
peek( 'Sales', 0, 'Tab1' ) returns the value of Sales from the first record read into the input table labeled Tab1.
Load A, B, numsum( B, peek( 'Bsum' ) ) as Bsum...; creates an accumulation of B in Bsum.
FieldValue(fieldname , n )
Returns the field value found in position n of the field fieldname (by load order). fieldname must be given as a string value, e.g. the field name must be enclosed by single quotes. The first field value is returned for n=1. If n is larger than the number of field values, NULL is returned.
Note: This function will only work with distinct field values.
FieldValue( 'HelpText', 5 )
FieldIndex(fieldname , value )
Returns the position of the field value value found in the field fieldname (by load order). If value cannot be found among the field values, 0 is returned. fieldname must be given as a string value, e.g. the field name must be enclosed by single quotes.