
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:
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
- Tags:
- new_to_qlikview
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Autogenerate(1) will do.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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');

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"

- « Previous Replies
-
- 1
- 2
- Next Replies »