Home
Sort, combine, keep a subset

We're going to show some basic operations that select data, sort it, and then filter it.

Script Overview 

The script in the following section was recorded while using Author mode as explained in the first tutorial section.  The following notes describe each important command. 

  • AddData is used to load a CSV file or a nextanalytics optimized data file. As an alternative to AddData, you can also run a SQL query.
  • The Sort command sorts the rows based on the column you identify. If you want to write your script so that it works on a wide variety of files, you can use words like Last or First, indicating the last or first column. The Sort command is also available from Author Mode user interface if you want to experiment with it.
  • SelectRange selects the rows, starting at the position you indicate, for the number of rows that you indicate. SelectRange also works on the column axis. The SelectRange is available from Author Mode user interface in case you want to experiment with it.
  • KeepSelected removes anything that wasn't selected. This is also available from Author Mode user interface in case you would like to experiement with it.
In the following script, PageCaption and PageDescription commands provide "business context" for each page being displayed.
Script
  1. adddata, actuals.csv
  2. PageCaption , "This is sample sales data."
  3. PageDescription, "We're going to use it to show some basic operations to select data, sort it, and filter it."
  4. ;--------------
  5. Sort,Last,true
  6. PageCaption,Sorted by the Last Column
  7. PageDescription,"The sort operation is intuitive enough to always sort on the last column. This means when new data arrives in the database, the operation continues to perform its role."
  8. ;--------------
  9. SelectRange,row,0,5
  10. keepSelected
  11. PageCaption,Top 5
  12. PageDescription,"This operation shows how easy it is to select a subset of records and keep or remove the rest.  Forming subsets like this is an excellent first step towards using this subset either as a new calculation (using the Combine operation) or using this list to filter another list, perhaps made up of different metrics such as budget"

Results of the Script

This is sample sales data.
We're going to use it to show some basic operations to select data, sort it, and filter it.
Name Region Position 01/06 02/06 03/06 04/06 05/06 06/06 07/06 08/06 09/06 10/06 11/06 12/06
Ted Burton Central Account Manager 33,900 62,100 106,200 37,100 115,600 151,700 58,500 102,400 177,700 83,000 133,600 210,400
Nell Gordon Central Sr. Account Manager 87,200 172,700 300,100 85,700 49,400 47,500 68,700 11,400 123,200 109,200 202,100 152,400
Bonnie Mills Central Account Manager 25,800 75,100 77,300 71,500 32,900 14,700 44,000 13,400 227,000 98,400 120,000 173,800
Juan Perez Central Account Manager 25,000 32,900 117,600 67,900 104,600 62,700 55,600 54,800 18,000 18,500 109,600 233,000
Jonathan Ryan Central Account Representative 0 0 0 0 0 0 16,600 32,000 34,800 6,700 4,800 84,800
Marcus Saul Central Account Manager 25,000 46,000 22,500 25,800 76,400 199,200 11,100 67,800 203,300 44,100 65,300 193,500
Jerry Wong Central Sr. Account Manager 99,000 159,700 63,200 7,200 169,700 286,200 83,700 231,600 251,700 155,600 208,000 314,900
Will Hill Federal Account Representative 16,200 15,700 22,300 13,500 43,100 29,900 11,900 46,600 44,200 32,000 6,100 122,600
Gil Jacobs Federal Account Manager 57,600 42,500 88,200 23,600 74,700 186,400 66,400 113,700 214,900 18,300 142,700 198,700
Larry Kelley Federal Account Manager 1,200 22,900 97,400 68,700 99,200 38,100 86,900 107,600 31,700 63,900 109,500 203,800
Sorted by the Last Column
The sort operation is intuitive enough to always sort on the last column. This means when new data arrives in the database, the operation continues to perform its role.
Name Region Position 01/06 02/06 03/06 04/06 05/06 06/06 07/06 08/06 09/06 10/06 11/06 12/06
Stephan Lauzon Northeast Sr. Account Manager 124,300 17,300 244,300 51,600 124,100 178,400 21,000 193,300 12,500 89,600 45,600 389,400
Ricki Murphy Southeast Sr. Account Manager 21,200 54,800 308,700 76,800 199,300 94,100 123,400 96,600 229,500 58,300 113,100 327,600
Jerry Wong Central Sr. Account Manager 99,000 159,700 63,200 7,200 169,700 286,200 83,700 231,600 251,700 155,600 208,000 314,900
Susan Ball West Sr. Account Manager 93,400 119,300 39,400 13,200 148,400 192,900 57,000 25,600 270,800 127,500 220,000 276,600
John Wells International Sr. Account Manager 42,000 78,700 54,600 61,500 170,000 227,100 126,400 108,000 80,700 96,200 167,100 250,400
Juan Perez Central Account Manager 25,000 32,900 117,600 67,900 104,600 62,700 55,600 54,800 18,000 18,500 109,600 233,000
Mike Chang Northeast Account Manager 39,500 85,900 15,300 18,000 101,500 32,900 47,200 135,000 175,400 86,600 21,800 228,000
John Smith Southeast Account Manager 18,300 102,700 64,700 9,900 42,700 185,500 91,700 25,600 32,400 89,900 18,400 221,800
Connie O'Brien Southeast Account Manager 70,400 44,600 134,000 21,400 115,000 161,500 18,700 100,300 36,700 83,800 35,200 211,400
Ted Burton Central Account Manager 33,900 62,100 106,200 37,100 115,600 151,700 58,500 102,400 177,700 83,000 133,600 210,400
Top 5
This operation shows how easy it is to select a subset of records and keep or remove the rest. Forming subsets like this is an excellent first step towards using this subset either as a new calculation (using the Combine operation) or using this list to filter another list, perhaps made up of different metrics such as budget
Name Region Position 01/06 02/06 03/06 04/06 05/06 06/06 07/06 08/06 09/06 10/06 11/06 12/06
Stephan Lauzon Northeast Sr. Account Manager 124,300 17,300 244,300 51,600 124,100 178,400 21,000 193,300 12,500 89,600 45,600 389,400
Ricki Murphy Southeast Sr. Account Manager 21,200 54,800 308,700 76,800 199,300 94,100 123,400 96,600 229,500 58,300 113,100 327,600
Jerry Wong Central Sr. Account Manager 99,000 159,700 63,200 7,200 169,700 286,200 83,700 231,600 251,700 155,600 208,000 314,900
Susan Ball West Sr. Account Manager 93,400 119,300 39,400 13,200 148,400 192,900 57,000 25,600 270,800 127,500 220,000 276,600
John Wells International Sr. Account Manager 42,000 78,700 54,600 61,500 170,000 227,100 126,400 108,000 80,700 96,200 167,100 250,400

 

 
< Prev   Next >