Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
Have a look at the CROSSTABLE function.
http://community.qlik.com/blogs/qlikviewdesignblog/2014/03/24/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.
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.
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