21.01.2013 Views

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

QlikView Reference Manual.pdf - QlikCommunity - QlikView

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This function can be used for mapping parts of any expression on a previously loaded mapping table. The<br />

mapping is case sensitive and non-recursive. The substrings are mapped from the left to the right. Mapname<br />

is the name of a mapping table previously read by a mapping load or a mapping select statement (see Mapping<br />

(page 253)). The name must be enclosed by single straight quotation marks. Expr is the expression<br />

whose result should be mapped by substrings.<br />

Examples:<br />

// Assume the following mapping table:<br />

map1:<br />

mapping load * inline [<br />

x, y<br />

1, <br />

aa, XYZ<br />

x, b ] ;<br />

MapSubstring ('map1', 'A123') returns 'A23'<br />

MapSubstring ('map1', 'baaar') returns 'bXYZar'<br />

MapSubstring ('map1', 'xaa1') returns 'bXYZ'<br />

Back to Other Functions.<br />

Inter Record Functions<br />

These functions are used when a value from previously loaded records of data is needed for the evaluation of<br />

the current record.<br />

exists(field [ , expression ])<br />

Determines whether a specific field value exists in a specified field of the data loaded so far. Field is a name<br />

or a string expression evaluating to a field name. The field must exist in the data loaded so far by the script.<br />

Expr is an expression evaluating to the field value to look for in the specified field. If omitted, the current<br />

record’s value in the specified field will be assumed.<br />

Examples:<br />

exists(Month, 'Jan') returns -1 (true) if the field value 'Jan' is found in the current content of<br />

the field Month.<br />

exists(IDnr, IDnr) returns -1 (true) if the value of the field IDnr in the current record already<br />

exists in any previously read record containing that field.<br />

exists (IDnr) is identical to the previous example.<br />

Load Employee, ID, Salary from Employees.csv;<br />

Load FirstName& ' ' &LastName as Employee, Comment from Citizens.csv<br />

where exists (Employee, FirstName& ' ' &LastName);<br />

Only comments regarding those citizens who are employees are read.<br />

Load A, B, C, from Employees.csv where not exists (A);<br />

This is equivalent to performing a distinct load on field A.<br />

previous(expression )<br />

Returns the value of expression using data from the previous input record that was not discarded due to a<br />

where clause. In the first record of an internal table the function will return NULL. The previous function<br />

may be nested in order to access records further back. Data are fetched directly from the input source, making<br />

326

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!