Sorting order

<< Click to Display Table of Contents >>

Navigation:  Report Generator > Report definitions in detail > The Settings 1 tab > Sorting >

Sorting order

Previous pageReturn to chapter overviewNext page

The sorting mainly implies that the records (rows) included in the report are sorted in the same order as they are going to be presented. It is possible to sort on several notations (columns) with different priority.

 

Feel free to compare with the telephone book that was used during the stone age to find the telephone number of a certain person. The telephone book was sorted by surnames on the first hand and by first names on the second hand. (That was for most countries, except for Iceland where the opposite was true). In the same way a report can be sorted on different notions, for example first on plant, then on location, and after that on something else.

 

To specify how the sorting should be done, you use the good old report variables that have one more use here.

 

The basis of the sorting process is the comparison between field contents in different records (rows). By comparing two text or number values with each other, it is possible to decide which one to place first. By comparing all rows with each other in that way, a complete sorting order can be decided.

 

The specific comparison can be done in several ways depending on the type of data concerned. In some cases, numerical sorting is preferable, meaning that the sorting is made with the field content considered as numerical values. For example, 2 will be considered less than 100, that is 2 is to be placed before 100. (That is not the case with an alphabetical sorting). In some other cases, alphabetical sorting is preferred. Then ABB is placed in front of Siemens, that is ABB is “less than” Siemens from an alphabetical point of view.

 

Please note that 100 is less than 2 from an alphabetical point of view! That somewhat surprising fact is understandable if you think about how an alphabetical comparison is done. First, the first character is compared. If they are equal, the second character is compared and so on. Since the first character in “100” is “1” and one is less than two, then “100” must be less than “2”. That is in fact true, when we consider it from an alphabetical point of view.

 

The discussion above is mirrored in the notion “adjustment” in the report definition. The possibility to use different kinds of sorting is implemented by applying adjustments to the compare texts before the comparisons are made. In that way, the wished result can be received.

 

The adjustments (sorting methods) available are as follows:

 

Adjustment

Description

No adjustment:

The sorting is made directly on the content of the field without any preceding adjustment. If the field content is adjusted to the left as default, this implies an alphabetical sorting. In most fields the data is adjusted to the left. Therefore, this method can be used for alphabetical sorting in most cases.

 

Example:

123

3

5

78

Andersson

Lindstrom

Peterson

 

Numerical adjustment:

The field content is adjusted to the right using spaces as padding character before the sorting begins. This implies that numerical values (integers) will be sorted correctly since space is considered as the very first character in the alphabet. Texts, however, will not be sorted alphabetically, unless all texts have identical lengths, which is probably a rare occasion.
 
Example:

      7

     45

     67

    123

 

Alphabetical adjustment:

The field content is adjusted to the left before the sorting begins. Due to this, the texts will be in correct alphabetical order even if the field contents were not adjusted to the left at the beginning. In most cases, Alphabetical adjustment, and No Adjustment, give the same result.

 

No sorting:

This alternative is in fact not used for sorting at all. It implies that another specified function should be used for the specified variable, while no sorting at all should not be made on it. In parenthesis, it can be mentioned that there are situations where sorting is strictly prohibited. One such situation is terminal lists with links).

 

 

You specify how the sorting shall be made, in the sorting table found to the right in the Settings 1 tab, by entering the report variables that the sorting is going to be made on, in the priority order you prefer. Higher priority should be located higher up in the table, and vice versa. For each variable you specify which adjustment to be used, the alternatives being described above.

 

The adjustments are specified directly in the table.

 

In the Report variable column, you enter the names of the report variables the Report Generator will use for the sorting.

 

You can type the variable names directly in the table. You can click twice in the field as well. (There must be two single clicks and not one double-click). A select button is then displayed, which you can use to activate a selection dialogue box. In that dialogue box, you can select variable from a complete list with all report variables, including descriptions of them all.

 

Click twice in the Adjustment column to select adjustment. Then a drop-down icon appears. By using that, a drop-down list appears, where you can select one of the adjustment alternatives described above.

 

Figure 1358:  Selection of text adjustment

Figure 1358:  Selection of text adjustment

 

For texts, you should select either No adjustment or Alphabetical adjustment. Use Numerical adjustment for numerical values only (preferably integers).

 

As said before, the variable on the top of the table has the highest priority.