Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

silviacico
New Contributor II

Match fct

Hi all,

I have a problem with my QlikView project: I have to do a match function between a field and a variable, but it does not seem to work fine (in this way it gives as error "Field not found"

FOR i = 0 to  $(noRows) - 1
LET BU = peek('BU_file', $(i));

NoConcatenate
StagingBU:
load *,
Resident Staging
where match(BU_file, $(BU));

next i

I have also tried to do:

FOR i = 0 to  $(noRows) - 1

LET BU = FieldValue(peek('BU_file', $(i)),$(i));

load *,
'$(BU)'
as Field1
Resident Staging
where match(BU_file, Field1);

next i ;

but is still not working.

Thanks!

Tags (2)
1 Solution

Accepted Solutions

Re: Match fct

Try doing this:

Temp:
LOAD Concat(DISTINCT BU_file, '|') as List
Resident Stag_BU;

LET vList = Chr(39) & Peek('List') & Chr(39);
DROP Table Temp;

FOR i = 1 to  $(noRows)
LET BU = Chr(39) & SubField($(vList), '|', $(i)) & Chr(39);

NoConcatenate
StagingBU:
load *
Resident Staging
where match(BU_file, $(BU));

store StagingBU into $(path_qvd)Staging_$(BU)_$(ANNO)_$(MESE).qvd (QVD);

DROP Table StagingBU
NEXT
i

14 Replies

Re: Match fct

Give this a try:

FOR i = 0 to  $(noRows) - 1
LET BU = Chr(39) & Peek('BU_file', $(i)) & Chr(39);

NoConcatenate
StagingBU:
load *,
Resident Staging
where match(BU_file, $(BU));

NEXT
i

silviacico
New Contributor II

Re: Match fct

Thank you for your answer,

with your script the loop takes a correct value with the first play (i=0) but then BU takes value " ' ' "

Cattura.JPG

Re: Match fct

Try this:

Temp:

LOAD Concat(BU_file, '|') as List

Resident Staging;

LET vList = Chr(39) & Peek('List') & Chr(39);

DROP Table Temp;

FOR i = 0 to  $(noRows) - 1
LET BU = Chr(39) & SubField($(vList), '|', $(i)) & Chr(39);

NoConcatenate
StagingBU:
load *,
Resident Staging
where match(BU_file, $(BU));

NEXT
i

silviacico
New Contributor II

Re: Match fct

I need again your help, if I try to do this, it creates all the different QVD with correct names but it takes only records where BU_file = APP (instead it gives all the BUs names to QVDs)

Temp:

LOAD Concat(BU_file, '|') as List
Resident Stag_BU;



LET vList = Chr(39) & Peek('List') & Chr(39);
DROP Table Temp;



FOR i = 1 to  $(noRows)
LET BU = Chr(39) & SubField($(vList), '|', $(i)) & Chr(39);


NoConcatenate
StagingBU:
load *
Resident Staging
where match(BU_file, $(BU));

store StagingBU into $(path_qvd)Staging_$(BU)_$(ANNO)_$(MESE).qvd (QVD);

NEXT i

Re: Match fct

Try adding Distinct to the Concat function:

Temp:
LOAD Concat(DISTINCT BU_file, '|') as List
Resident Stag_BU;

LET vList = Chr(39) & Peek('List') & Chr(39);
DROP Table Temp;

FOR i = 1 to  $(noRows)
LET BU = Chr(39) & SubField($(vList), '|', $(i)) & Chr(39);

NoConcatenate
StagingBU:
load *
Resident Staging
where match(BU_file, $(BU));

store StagingBU into $(path_qvd)Staging_$(BU)_$(ANNO)_$(MESE).qvd (QVD);

NEXT
i

silviacico
New Contributor II

Re: Match fct

There's the same problem, it only takes data with BU_file= APP, this means that the code not working is:

where match(BU_file, $(BU));

I also tried with BU_file = $(BU) but still not working

Not applicable

Re: Match fct

Match is a string function and so the second variable  in Match function also need string. So try like below:

Match(FieldName,'$(varibale)')

silviacico
New Contributor II

Re: Match fct

Hi, in particular the code is working fine with the first value of the variabile BU (BU=APP) but then it's like the loop of loading and creating new QVDs is going on but not the where condition that is still "freezed" at BU=APP,

thanks

Re: Match fct

Try doing this:

Temp:
LOAD Concat(DISTINCT BU_file, '|') as List
Resident Stag_BU;

LET vList = Chr(39) & Peek('List') & Chr(39);
DROP Table Temp;

FOR i = 1 to  $(noRows)
LET BU = Chr(39) & SubField($(vList), '|', $(i)) & Chr(39);

NoConcatenate
StagingBU:
load *
Resident Staging
where match(BU_file, $(BU));

store StagingBU into $(path_qvd)Staging_$(BU)_$(ANNO)_$(MESE).qvd (QVD);

DROP Table StagingBU
NEXT
i

Community Browser