Documentation/How Tos/Using Data Ranges, Data Sort and Data Filters
Using Data Ranges, Data Sort and Data Filters
Defining your Ranges
Working with data ranges enables you to select them very easily, carry out sorting operations, or filter the data using the column and row headers, and thereby avoid risky manual data manipulation.
- Enter your data and organize as you usually do,
- Highlight what you want to become your data range; don't forget to include your column headers,
- click on Data > Define range...
You will see the range that you have selected highlighted in the background.
- Give a name to the range designated in the Range field.
If the range isn't what you want click the icon next to the Range field and select another range.
- Click the More button to see additional options:
- Don't forget to check the box Contains column labels, so that your headers are recognized when you carry out sorting
- The Insert or delete cells box allows you to insert or delete data in the range selection
- The Keep formatting box tells OpenOffice.org to keep the formatting of any new data that you might subsequently enter.
- The Don't save imported data box refers to data that you may have called from a database, so these data will not be saved with your file.
- Click OK to close the dialog box and return to your document.
You can define as many ranges as you want; all you have to do is repeat the procedure explained above, and click the Add button in the dialog box. The same applies if you want to delete a range, select the range you want and click on the corresponding button in the dialog box.
Selecting a Range
Once you have entered your ranges, select the one that you wish to work with as follows:
- Select Data > Select range from the menu.
- Select a data range and click OK
The data range will appear highlighted in your document.
To sort your data:
- Select the range that you want to work with
- Select Data > Sort from the menu
On the Sort Criteria tab you can define up to 3 criteria. Here, we've decided to do an ascending sort, first by Gender, then by Age.
- Specify the sort options on the Options tab
All of these options will enable you to edit your sort operation in the same table or a similar table at the area you have specified previously (in our example, we chose to copy the result just below the first table).
Here is the result :
The use of filters is as simple as sorting:
- Select the range that you want to work with
- Select Data > Filter > Standard Filter... from the menu
- Fill in the data field names on which you want to base your filter by selecting them in the drop-down menu.
- Here again, you can use up to 3 criteria with Boolean operators (and, or) and other conditions. The value is represented by the data on which the filter is to be carried out in relation to the field name chosen.
- The More button, enables you to edit a table, taking into account regular expressions, case sensitivity or duplicates.
Here's the result:
The Autofilter is slightly different from the standard filter. In order to understand what it does, let's use it and see what we get.
There is a small button with an arrow next to each field name. Click on the one next to the field Name to see what it does.
As you will have noticed, the list of names represents the filter criteria and you can apply them differently to each column. If you select Standard, the Standard Filter dialog appears.
Let's click on Dupont and observe the result obtained: The criteria corresponding to the name Dupont, and only Dupont, are displayed.
To cancel the filter operation:
- Select the range
- Select Data > Filter > Autofilter from the menu
The advanced filter is a filter that lets you use more than 3 filter criteria, up to a maximum of 8.
In order to use this filter, you have to create an array in which you'll enter the criteria. Let's start from the example we already have:
- Copy the row with the field names of your range (Name, Age...) into empty cells on your sheet, for example at row 10
- Enter your sort criteria, under each column. Note that criteria on a same 'row' are combined by an OR, while criteria in the same column are combined as AND. In order to enter names with the equals sign, don't forget to put in quotation marks (). Here's the result
In this example, we are searching for people whose age is less than 25 AND (since the criterion appears under the preceding one) whose salary is greater than 35000. Here are the results after applying the filter:
So, after having created your array
- Select the data range to which the filter should apply.
- Select Data > Filter > Advanced Filter from the menu.
- In the window that appears, select the array that you defined at rows 10 to 12 using the selection button.
- In the options (click More), also indicate where you want your filtered data to appear (we put it at row 17)
- Click OK.
|Content on this page is licensed under the GNU Free Documentation License (FDL).|