Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Loop through rows of a Straight Table (Chart)

I have successfully combined multiple tables into an inner joined straight table.  I know how to loop through the rows of a single table.  Is it possible to loop through the rows of a straight table using script?

Jerry

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

For i = 1 to noofRows(table)

    let myvalue =  peek('field', $(i))

next

Anonymous
Not applicable
Author

A straight table (chart) object is not a regular table.  I have tried using the object name as the table name and using the caption, but neither version will return the number of rows.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

No, you cannot access a sheet object from script. You will need to create a qv table in the script that mimics the contents of the straight table object.

-Rob

Not applicable
Author

Yes you can loop through the records from script:

sub ReadTable

set table = ActiveDocument.GetSheetObject( "CH218" ) ' Use Object ID

  for RowIter = 1 to table.GetRowCount-1

    for ColIter = 0 to table.GetColumnCount-1

      set cell = table.GetCell(RowIter,ColIter)

      msgbox(cell.Text)

    next

  next

end sub

Above works perfectly for me.

Its even possible to insert, and update records too.

Regards

Corrie