Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Highlighted
Not applicable

Looping through a crosstable

Hi All.

Is there something special about looping though a crosstab? I am getting very odd results with the following approach.

FOR  vRowCounter = 1 TO NoOfRows('MasterScoreXTAB')

     LET vField1  = FieldValue('Field A',vRowCounter);

     LET vField2  = FieldValue('Field B',vRowCounter);

     LET vField3  = FieldValue('Field C',vRowCounter);

     Trace =====> $(vField1) ++ $(vField2) ++$(vField3)

NEXT

With this construct I am expecting to see each fields of the Crosstab row side-by-side. But $(vField2) is showing values from a different row in the crosstab, as if vRowCounter was being incremented several times within a single loop cycle.

Any hint?

Tags (2)
4 Replies

Re: Looping through a crosstable

Not applicable

Re: Looping through a crosstable

Thanks Collin.

My table was indeed created using the Crosstable Load function, but I am not sure what the article your refer to means for my issue. I have read through all the subsequent posts, and I didn't find a mention about looping through a crosstable.

MVP & Luminary
MVP & Luminary

Re: Looping through a crosstable

The fieldvalue function gets data from an internal symbol table, not the table you created with the crosstable function. The record numbers of the symbol table are completely unrelated to the record numbers of the table the crosstable function created.


talk is cheap, supply exceeds demand
Not applicable

Re: Looping through a crosstable

Thanks Gysbert.

And indeed, using peek works, like so:

FOR  vRowCounter = 1 TO NoOfRows('MasterScoreXTAB')

     LET vField1  = Peek('Field A',vRowCounter);

     LET vField2  = Peek('Field B',vRowCounter);

     LET vField3  = Peek('Field C',vRowCounter);

     Trace =====> $(vField1) ++ $(vField2) ++$(vField3)

NEXT