Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using the function peek

Hello everyone,

I am new on QlikView and i´m trying to peek the 3rd value from a field using the function peek.

Below is the field that i am trying to peek the 3rd value:

peek.JPG


The name of the table is 'TreinamentosSP', sou i did that in the script:

varParticipacao = peek('[% de Participação]', 3, 'TreinamentosSP');
Participacao:
LOAD $(varParticipacao) as Participacao
FROM TreinamentosSP;

When i run the script, i receive error msg from QlikView.

Somebody can help me to understand what it is wrong?

Thanks in advance,

Rodrigo

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Don't get confused with some additional code just for demonstration.

If I see correct what needs to be changed according to Maxgro's sample, you need

1) Use LET statement in variable definition

2) Remove the [..] from field name literal

3) Use 2 instead 3 as row indicator (QV starts counting rows from 0 in peek() function)

Original:

varParticipacao = peek('[% de Participação]', 3, 'TreinamentosSP');


Maxgro's:

let varParticipacao = peek('% de Participação', 2, 'TreinamentosSP');

Check in script debugger or using TRACE statement as shown above that the variable then contains the correct result.

View solution in original post

10 Replies
maxgro
MVP
MVP

TreinamentosSP:

load * inline [

% de Participação

427

341

80

1

2

3

];

let varParticipacao = peek('% de Participação', 2, 'TreinamentosSP');

trace varParticipacao=$(varParticipacao);

Participacao:

NoConcatenate LOAD $(varParticipacao) as Participacao

Resident TreinamentosSP;

Not applicable
Author

Hi maxgro,

Thanks for your answer!!

I did what you suggested, but i received the following QlikView error message:

"Sintax error, clause FROM missing or in the wrong position:

Participacao: NoConcatenate LOAD   as Participacao

Residente TreinamentosSP"

Do you know why i am recieving this error?

Just to clarify, the value i need capture from the field '% de Participação' is dynamic, so i can´t create the table 'TreinamentosSP', with the fixed values 427, 341, 80, because they will change constantlty.

Regards,

Rodrigo

maxgro
MVP
MVP

I did an inline load because I don't have your data

I suppose in your script you have a load of TreinamentosSP in place of my inline load

Could you post your script?

Digvijay_Singh

I think you don't need

     'FROM TreinamentosSP;'


You have read one value from TreinamentosSP and assigned that value in variable;

now you are creating new field from this variable and and creating new table, why do you need table TreinamentosSP while creating new table.


May be I am missing something.

Digvijay_Singh

Autogenerate(1) will do.

swuehl
MVP
MVP

Don't get confused with some additional code just for demonstration.

If I see correct what needs to be changed according to Maxgro's sample, you need

1) Use LET statement in variable definition

2) Remove the [..] from field name literal

3) Use 2 instead 3 as row indicator (QV starts counting rows from 0 in peek() function)

Original:

varParticipacao = peek('[% de Participação]', 3, 'TreinamentosSP');


Maxgro's:

let varParticipacao = peek('% de Participação', 2, 'TreinamentosSP');

Check in script debugger or using TRACE statement as shown above that the variable then contains the correct result.

cjohnson
Partner - Creator II
Partner - Creator II

Hi Rodrigo,

Did you try enclosing your variable with single quotes in the load - such as what is shown below?

varParticipacao = peek('[% de Participação]', 3, 'TreinamentosSP');
Participacao:
LOAD '$(varParticipacao)' as Participacao
FROM TreinamentosSP;


What error are you getting when the script is executed?


Thanks,

Camile

cjohnson
Partner - Creator II
Partner - Creator II

Also, I don't see a "let" statement when you are setting your variable value. Is that included?

So,

LET varParticipacao = peek('% de Participação', 3, 'TreinamentosSP');

Not applicable
Author

Hi Camile,

When i use single quotes in the load, the variable value returns empty (blank).

Below is my script:

LET varParticipacao = peek('[% de Participação]', 2, 'TreinamentosSP');
TRACE varParticipacao=$(varParticipacao);

Participacao:
NoConcatenate LOAD $(varParticipacao) as Participacao
Resident TreinamentosSP;


While running the script, QlikView displays the error message below:

"Sintax error, clause FROM missing or in the wrong position:

Participacao: NoConcatenate LOAD   as Participacao

Residente TreinamentosSP"