The [highlight txt=’sort’] instruction allows a user to sort the data within a particular Excel worksheet.[message type=”warning”]For the purposes of this article we are going to use a simple and fictitious Excel file. It has already been uploaded into a data step. You will want to replace this file with one of your own.[/message]
Before we get started
Please further create a ‘Manipulate a file’ or ‘Multiple file manipulations’ action step so that you can add and use instructions.
The target file that we are going to use looks like this:
We want to sort this data firstly by the numbers in ColumnA and then by the letters in ColumnC.
1. Create a ‘Sort’ instruction.
2. Link the file named “Target” as the target file.
3. Select Sheet1.
4. Use an Advanced Cell Range from cell A1 to the last cell in column A as far as C.
5. The instruction allows for up to 5 levels of sorting. The configuration section for ‘Column1’ (the first level) should be enabled by default.
6. The variable option for the column name should be selected/populated to “A” by default. The instruction will therefore use ColumnA as the first level of sorting.
7. The sorting order should be set to ‘Asc’ by default. The instruction will therefore sort the data with respect to ColumnA in an ascending order (i.e. “1, 2, 3”).
8. Tick the box next to ‘Column2’ to enable the configuration section for a second level of sorting.
9. Adjust the variable option to “C” by clicking on the field immediately below the tick (the field should be selected/populated to “A” by default). Clicking on this field will open up a dropdown. Select “C” from this dropdown.
10. Alternatively, type “C” into the field next to the variable option.
11. The sorting order should be set to ‘Asc’ by default. The instruction will therefore sort the data with respect to ColumnA in an ascending order, then with respect to ColumnC in an ascending order.
12. Save and run the step.
13. After the step finishes running, download and open the target file: