Sorting Reports


Navigation:  USING REPORTS >

   Sorting Reports

There is a Sort button on the reports viewing window. This option allows you to change the order of the data displayed on the report, if you want to see it in another order. For instance, suppose you want to list accounts in descending order by account number. You might start by creating the Reports ⇒ Listing Chart of Accounts report. Then click the Sort button. (Please do this as you are reading this page or it will be difficult to understand it!)


You will now see the following window, called Specify Sort Columns:




Instructions are written at the top of the window. Basically, the box at the left labelled "Source Data" contains the names of all of the fields on the report that you can sort on. While the names displayed won't exactly match the column headings on the report, you should be able to easily figure out which is which, for almost all reports. (You can always try some trial and error.)


Although most reports are sorted, the current sort order may or may not already be displayed in the box on the right when you bring up this sort window for the first time for a given report. That's for technical reasons, which are a bit hard to explain. In any case, it should be pretty easy to see what the current sort order is, by looking at the report before you click Sort.


In the example described above, you want to sort on the Number column, and the obvious guess is a column called "number". Click on that and drag it over to the box on the right labelled "Columns". You will see a checkbox to the right of where the name appears, labelled Ascending, which is checked. We want to see it in descending order (from the highest down to the lowest Number), so click that checkbox to uncheck it. Now click on the OK button and it will sort your report in the order you requested.


You can even sort on more than one column by dragging a second column over from the "Source Data" list to the "Columns" list. When you do that, it first sorts by the first column listed, and then it only sorts on the 2nd column listed if the values in the 1st column are the same.


You can remove a column from the sort by dragging it back from the "Columns" box to the "Source Data" box. Please note, however, that if you remove all of the sort columns, the report won't necessarily go back to its original order. To get back to that order, Close the report and create it again from the Reports menu. Each time you create this report, it will be displayed in its original order. Your sort order from a previous run is not remembered. However, you can memorize the report, which memorizes both any Sort and any Filter that you put on the report, and allows you to re-use it later.


Some reports may not work properly with arbitrary Sort orders. For those reports, the Sort button may be disabled.


When you change the sort order, part of the header of most reports will change to reflect the new order you have chosen. The only exception to this is if you also change the filter (see the previous section), in which case the revised filter criteria will show in the header instead.


Problem with Descending Sorts with Large Fonts set on your Computer


If you have large fonts set on your computer, the Ascending column may not be visible in the Sort dialog box, and as a result, it may be impossible for you to change a sort order to be Descending by unchecking the Ascending checkbox. (I'm sorry, this is a bug in the program we use to create ACCOUNTS, PowerBuilder, and we can't do anything about it.)


In many cases you may be able to work around this. The trick is that if you double-click on a selected sort Column in the right-hand side of the dialog box, a further dialog box comes up that allows you to change it from just a column name to a calculated expression.


Suppose the column you wanted to sort Descending on was "amount" (without the quotes, of course). After double-clicking on the "amount" column name at the right, in the dialog box that comes up, change "amount" to "-amount", without the quotes, then click OK. Sorting Ascending on a negative amount gives the same result as sorting Descending on a positive amount, so you will get the result you want, even though you can't change it from Ascending. This same trick will work with any numeric field.