Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

andriesb
Contributor

Script mapping load uses variable for subfield.

I have a 'normal loading procedure and a mapping load. I would like to pass a variable to pass to this mapping load to be used within a subfield.

Within this example : the outcome of ApplyMap('Contact', Rel_Source_ID, '') is stored to the variable $Variable. This value $Variable should be used to read the nth field of the field Itemlijst where the Source_ID is the 'search string' for this mapping.

//Search nth items from list

ContactListText:

MAPPING LOAD  Source_ID,   // bedr  + rel code + middel

             SubField([Itemlijst],';',$Variable)                // rubriek waarde

from xxxx;

Load *,

     applymap ('ContactListText', Rel_Source_ID, 'blanc') as RelText

load *,

ApplyMap('Contact', Rel_Source_ID, '')      AS $Variable,

resident Sourcetable.

How many items the itemlist contains, could vary

4 Replies
MVP & Luminary
MVP & Luminary

Re: Script mapping load uses variable for subfield.

A load statement returns records with fields that have values. A load statement cannot directly assign a value to a variable. So applymap cannot store a value in a variable. The AS $Variable would create a field named $Variable.

If you want to use the variable in the subfield function then you need to create that variable before creating the mapping table. The mapping table must exist before an applymap can use it to look up values.


talk is cheap, supply exceeds demand
andriesb
Contributor

Re: Script mapping load uses variable for subfield.

Oke, I only could store my outcome into a fieldname. Would that help me as I only could pass one parameter within the "applymap"

Two questions remains:

1. How to store a field value within the LOAD to a (global) variable

2. Could I use this variable within my mapping request as I only could pass 1 parameter to the applymap.

I have to search using two parameters: the first param is Rel_Source_ID and the second this variable (to be used within my SubField request...

MVP & Luminary
MVP & Luminary

Re: Script mapping load uses variable for subfield.

  1. Use the peek function. For example:

    Temp:
    Load max(Amount) as MaxAmount from somewhere;
    LET vMax = peek('MaxAmount');
    DROP table Temp;

  2. MyMap:
    Mapping Load FieldA, subfield(FieldB,';',$(vMax)) as FieldC from somewhereelse;


talk is cheap, supply exceeds demand
andriesb
Contributor

Re: Script mapping load uses variable for subfield.

sorry G Wassenaar, but not sure how to use your suggestion within my problem..? For each record these values could vary, so using Max() is not an option.