instructional systems
Index:
[Session3] Application software: Office tools
1 Chapter1
2 Chapter2
3 Chapter3
Your Location: Home Page  >  [1] Information literacy  >  [Session3] Application software: Office tools  >  Chapter3  >  3.6 Sorting and Judging by Conditions
Sorting and Judging by Conditions
[The purpose of this section]
Practice ascending and descending data sorting and criteria judging.

Sorting

[Practice 19]
Using the ex2.sxc on which you have been working, learn how to use sorting features and rank the test scores according to the following procedure. Do not forget to overwrite save the file.

Data can be sorted by the order of the numeric data or text data using a certain row or column as a sorting key.

There are two sorting orders, ascending order and descending order, as follows.

  • Ascending order:the smallest value (number), or alphabetic character “a” (letter) comes first.
  • Descending order:the largest value (number), or alphabetic character “z” (letter) comes first.
In order to sort data, after selecting the rows or columns (or a range of cells) to be sorted, select “Sort” under the “Data” menu.
   The key rows or columns and sorting order, ascending or descending, should be specified next.

Let’s rank the test scores by specifying column G in which the total scores are input as the sorting key.

Select from the row 3 to the row 6 in which the personal data of the examinees is input.


Select “Sort” from the “Data” menu.


In the dialog box which appears in the window, select “column G” as the “first preference key”. Since the highest performance (highest score) should come first, check “descending” order.






(Note) The “Second preference key” and “third preference key” are used to determine the ranking when more than one student has the same scores.

Now, sorting has been completed as follows. You can see this from column G in which the total scores are displayed. Since sorting was performed in row units, the numbers, names, and scores for each subject were also moved together.


Since the data was sorted by the test scores, let’s input the ranking, too.
Just input “Ranking” in cell I2 to input ranking in column I, and “1” in cell I3, and copy the data using autofill to cell I6.







Judging by Conditions

[Practice 20]
In the file ex2.sxc, which you have been using, judge pass or fail of each student to practice the feature for displaying different texts depending on conditions according to the following procedures. Do not forget to overwrite save the file.

It may be a little sudden, but you sometimes change your behavior depending on the conditions, don’t you?

For example,
    it is likely to happen that you give a reduction of 20% to a nice-looking customer who is your type (saying, “Only for you.”),
    although you sell products to normal customers at a fixed price.

This behavior can be generalized as below.

After judging by conditions (whether or not a customer is nice-looking and your type) ;
  • If the condition is met (the customer is your type)
       → the predetermined action for a case where the condition is met is taken (give a reduction of 20%).
  • If the condition is not met (the customer is not )your type)
       → the predetermined action for a case where the condition is not met is taken (sell the products at a fixed price).

The situation that is generalized above often occurs in utilizing a spreadsheet, too. Thus, various functions to “judge by conditions and change behavior depending on the result” are available.

Here, we will use the function “if ()” which is the most typical of such functions.

The function “if” is used as follows.

  If (“condition”; “action for a case where the condition is met”; “action for a case where the condition is not met”)

The meaning of these three arguments is as follows.
  • In the condition part, a formula that contains comparison operators is written. Examples of comparison operators are shown below.
  • Comparison Operators
    Conditional Expression Meanings
    A = B A is equal to B.
    A <> B A is not equal to B.
    A > B A is greater than B.
    A >= B A is greater than or equal to B.
    A < B A is smaller than B.
    A <= B A is smaller than or equal to B.

  • In the part “action for a case where the condition is met”, formulas or data (texts or numbers) to be executed when the condition is satisfied are written in.
  • In the part “action for a case where the condition is not met”, formulas or data (texts or numbers) to be executed when the condition is not satisfied are written in.

Let’s use the function “if” as a formula to judge pass or fail in the scores.
Grant “pass” to students who got 400 points or more, and “fail” to those who got less than 400 points. Display the result in the column J.

Input text “Pass or Fail” in cell J2, and input the formula below in cell J3.

       = if (G3 > = 400; “pass”; “fail”)


Let me explain about the if function above.
  • “G3 > = 400” is the conditional statement to judge if the value in cell G3 is 400 or more. It would be “G3 > 400” to judge if the value is more than 400, and “G3 = 400” to judge if the value is 400.
  • (Note) Since the G3 in the above formula specifies the cell address, you can input it by clicking cell G3 with the mouse pointer as usual instead of directly inputting the text.

  • “Pass” is the part that specifies an action to be taken when the condition is met. The reason why “” (double quote symbols) are put on either side of the text “pass” is that this informs the function “if” (spreadsheet) that pass is text data. If these double quote symbols are not put in, “if” interprets “pass” as the name of the function or a cell, and normally an error occurs.

  • “Fail” is the part that specifies an action to be taken when the condition is not met. Around the text fail, the “” (double quote symbols) are placed, as with “pass” mentioned above.

(Note) When you input text data as the argument of a function, you need to enclose them using double quote symbols as above.

Copy the cell J3 down to K6 with autofill feature, and the task is completed.



Error List

Typical errors displayed in a cell are listed below. The causes of errors and their solution are described, too.

Error display
Cause
Solution or case
###### The cell is too small to display the data. Expand the cell (There is no problem if you leave the cell as it is.)
#DIV/0! The values are being divided by 0. Input a value other than 0. (Use of the IF () function)
#NAME An undefined name was used for the calculation. The spelling of the function is wrong.
#VALUE Data that cannot be used for the calculation is being used. Text data was input in a place where only numeric data is acceptable.
Copyright Ryuichi Matsuba and Kenichi Sugitani 2005, All Rights Reserved