Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
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
swuehl
MVP
MVP

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

View solution in original post

10 Replies
Anonymous
Not applicable
Author

Brandon,

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

Regards,

Michael

Not applicable
Author

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.

Anonymous
Not applicable
Author

It works for me with QVD load as well.

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

alexpanjhc
Specialist
Specialist

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

try debug reload see what that value is.

swuehl
MVP
MVP

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
Author

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
Author

Attached is the file with the oddity.

swuehl
MVP
MVP

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
Creator II
Creator II

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