What about using applymap outside of any table scope? Like in:
MAPPING LOAD * INLINE [
LET vResult1 = applymap('MapTable', 'ABC'); // with quotes
LET vLookup = 'DEF';
LET vResult2 = applymap('MapTable', vLookup); // without quotes
There are many variations possible in QlikView Script
You do not need to pass the field name in quotes for the peek function if there are no spaces in the field name if the peek function is used in the load script.
However, you need quotes if the peek function is called in a set/let statement and I think this is to cater for field names that may contain spaces in them.
You will be required to quote the field in apply map also ,if the field name contains a space.
As stalwar1 stated earlier , peek() has the power to pick fields from same table and different tables as well so '' will make sure of the filed name is correctly resolved because peek takes field name as String parameter so quotes will make sure its passed as string only.
that is not entirely correct, because 2nd parameter of ApplyMap is an Expression (not Field).
See below Exemple
LOAD * Inline [
LOAD *,ApplyMap('MapTable',Field) as MapField Inline [
LOAD *,ApplyMap('MapTable','A') as MapField1 Inline [
If I read all posts/replies correctly, I must say I beg to differ a little bit with many of them. Both peek() and applymap() are functions accepting expressions as parameters, but the parameters have a different character.
applymap(A, B) needs A to be a string and B must evaluate to a value to lookup (we'll omit the third parameter because not used in the OP)
peek(A, B, C) seemingly needs A and C to be strings and B must be an expression that evaluates into a row number/index.
What is clear to me if I think about it, is that both functions must receive table and field names in one case, and expression values in other cases. The names must be supplied because each function needs to know in what table (and which field) to go search for the required information. Simply mentioning a field name without quotes won't do, because that is either a reference to a QlikView field (an ordered series of values like what you pass to an aggregation function like sum()) or - and this depends on the context - a reference to a single field value whereby the value will be used instead of any other field characteristic - see the use of a field name in an expression inside an aggregation function call. So what happens when you specify an unquoted field name as parameter C in a call to peek (inside or outside of a LOAD statement)? Depending on the context, you'll be passing one or more field values to the peek() function. Which is probably not what the peek function expects.
Applymap() on the other hand will accept both an unquoted field name (in the proper context), and a quoted field name as parameter B. In the latter case, applymap() will simply look for the string in the lookup table.
However, I wouldn't be surprised that using a call format like
LOAD ..., peek('TableA', -1, UnquotedFieldName) AS ... FROM ...;
would also be ok, On condition that I could manage the input column UnquotedFieldName to contain 1 name of an existing input field. Not that it makes any sense, but I cannot think of a reason why this shouldn't be possible...
Does that make sense?