Makes the Coke column appear to the right of the Pepsi column. Refer to Making One Row Appear After Another for a detailed description of how this example works.
Using our cola data set, create a table of Q5, from the object inspector click Switch Rows and Columns. You can now create a custom rule using the following code:
//Move the Pepsi column to the right of the Coca Cola column
table.moveColumnAfter(table.columnIndex('Coca Cola'), table.columnIndex('Pepsi'));
If using the Q software: This example can be run in C:\Program Files\Q\Examples\Cola.Q (this may be located on a different place on your computer depending upon how Q was installed).
See also
- Making One Row Appear After Another.
- Table JavaScript and Plot JavaScript for an explanation of how to run this code.
- Table JavaScript and Plot JavaScript Reference for technical information.
- Table JavaScript and Plot JavaScript Examples Library for other examples.
- JavaScript for information about the JavaScript programming language.
- QScript for tools for automating projects using JavaScript.
- JavaScript Variables for detail on how to create new variables in the Variables and Questions tab using JavaScript.