Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

LET variable = PEEK('field1', 0, 'MyTable') not giving a value

Hi community,

I used the above code to store the value of a field of a table into a variable, the field only has one value, 2012.  Any ideas as to why this might be giving me nothing?  Am I missing something in the syntax?

1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

If I got it right, your MyTable has only one value in one row, but 19 rows in total, most of them NULL.

Peek() addresses a certain row in that table, but the first rows are all NULL, that's why you don't get a result back for your variable.

Let vVar2 = FieldValue('field',1);

does work in that case.

Hope this helps,

Stefan

10 Replies
mov
Esteemed Contributor III

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

Brandon,

I don't see anything wrong.  See the attched, compare with your application.

Regards,

Michael

Not applicable

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

Very Bizarre,

I works just fine when the table the variable comes from is from an inline table, but not when the table is loaded from a qvd.  In fact, the variable doesn't even show up in the document (when I try to put it as a variable in an input box.) after a reload unless it was already created.

mov
Esteemed Contributor III

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

It works for me with QVD load as well.

Are you sure that you do not delete your variable later in the script?

alexpanjhc
Valued Contributor

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

i am trying to think, maybe when you actually used this value, did you use $(variable)?

try debug reload see what that value is.

MVP
MVP

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

I believe the variable will not be created if the expression evaluates to NULL.

And QV won't give an error message if this happens.

Have you checked that table and field name are spelled correctly?

You can try, if these lines return any data:

Let vVar1 = peek('field',0,'MyTable');

Let vVar2 = FieldValue('field',1);

 

Let vVar3 = NoOfRows('MyTable');

Let vVar4 = FieldValueCount('field');

Would it be possible that you post your script code here?

Regards,

Stefan

Not applicable

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

I'm not going to lie folks.  I did find a work around but come Tuesday when I get back, I'll test your suggestions and post the document here too.

Not applicable

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

Attached is the file with the oddity.

Highlighted
MVP
MVP

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

If I got it right, your MyTable has only one value in one row, but 19 rows in total, most of them NULL.

Peek() addresses a certain row in that table, but the first rows are all NULL, that's why you don't get a result back for your variable.

Let vVar2 = FieldValue('field',1);

does work in that case.

Hope this helps,

Stefan

berndjaegle
Contributor

Re: LET variable = PEEK('field1', 0, 'MyTable') not giving a value

Hi Brandon,

had a similar issue, but in my case just 'quotes' were missing...

wrong:      peek(field,0,MyTable);

right:         peek('field',0,'MyTable');

Not the answer to your question, but might be helpful for others.

Regards,

Bernd