Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Strange problem with script

Here is a snippet of a script that I am working on:

DataRaw:

LOAD * Inline [

path, path_count

'String1',2

'String2',1

'String3',1

'String4',2

'String5',1

'String6',1

];

Let numRows = NoOfRows('DataRaw');

For myRow = 1 to NoOfRows('DataRaw')

  Let vFld = FieldValue('path',myRow);

    Let vCount = FieldValue('path_count',myRow);

    Let myPlace = 1;

Next myRow

The first two rows of the data process just fine but I am getting Null for the value of vCount at the third row and every row after that.  Here is my debug output.

2017-04-03_17-27-58.jpg

What am I doing wrong?

1 Solution

Accepted Solutions
craigsutton
Creator
Creator

I got the same result.  What about using Peek?  I had better luck with Peek.

DataRaw:
LOAD * Inline [
path, path_count
'String1',2
'String2',1
'String3',1
'String4',2
'String5',1
'String6',1
]
;


Let numRows = NoOfRows('DataRaw');

For myRow = 0 to (NoOfRows('DataRaw')-1)
Let vFld = Peek('path', myRow, 'DataRaw');
// Let vFld = FieldValue('path',myRow);
Let vCount = Peek('path_count', myRow, 'DataRaw');
// Let vCount = FieldValue('path_count',myRow);

Let myPlace = 1;

Next myRow

View solution in original post

3 Replies
craigsutton
Creator
Creator

I got the same result.  What about using Peek?  I had better luck with Peek.

DataRaw:
LOAD * Inline [
path, path_count
'String1',2
'String2',1
'String3',1
'String4',2
'String5',1
'String6',1
]
;


Let numRows = NoOfRows('DataRaw');

For myRow = 0 to (NoOfRows('DataRaw')-1)
Let vFld = Peek('path', myRow, 'DataRaw');
// Let vFld = FieldValue('path',myRow);
Let vCount = Peek('path_count', myRow, 'DataRaw');
// Let vCount = FieldValue('path_count',myRow);

Let myPlace = 1;

Next myRow

Anonymous
Not applicable
Author

Well after much hair pulling the solution seemed to be to use the Peek function instead of FieldValue and also specify the table name.  Additionally the first record for use with Peek is record 0.

So the script should look like this...

For myRow = 0 to NoOfRows('DataRaw')-1

  Let vFld = Peek('path',myRow,'DataRaw');

    Let vCount = Peek('path_count',myRow,'DataRaw');

    Let myPlace = 1;

Next myRow

Anonymous
Not applicable
Author

We were typing at the same time.  I'll mark yours as correct.