oracle excel part 2

Upload: kingofpeace

Post on 03-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Oracle Excel Part 2

    1/18

    Introduction to Expressions

    Types of Values

    Introduction

    An expression is a combination of values and symbols used to produce a new value. There aredifferent types of values involved in an expression. They are:

    A string is a character, a word, or group of words considered as an entity. Any combination of lettersor words you can think is primarily a string.

    A Boolean value is one that can be expressed in only one of two values, as either TRUE or asFALSE. A FALSE value also has the value of 0. In this case, any other numeric value is consideredTRUE. Boolean values are mostly used in comparisons.

    An integer is a natural number that displays without a decimal place. Examples of integers are 18,16763, and 1450. If the number is very large, it can be considered as a Long integer.

    A byte is a small integer that ranges from 0 to 255.

    A double, also called double precision, value is a number that can display a decimal portion, using thecharacter set as the decimal separator in Control Panel. For US English, that character would be theperiod. The expression "double-precision" means that this number provides a high level of precision. Ifyou are dealing with a decimal number but precision is not important, then the number can be representeas a Single. Valid decimal numbers are 12.55, 3.14159 or 9.80336.

    A date is a numeric value that counts the number of days that have elapsed from a certain point ofreference. How a date displays in a field is based on some conventions set by Microsoft Excel, MicrosofWindows, or you. There are also rules you must respect. Examples of dates are 28/06/1998, 10-8-82,January 10, 1865.

    A time is a numeric value that counts the number of seconds that have elapsed since midnight of a certaiday. The time also displays following some conventions set in Control Panel, by Microsoft Excel, or theperson who created the spreadsheet. Examples of time values are 10:42 AM and 18:06.

    The currency is a numeric value used to represent money. In some cases, you can use a double-precisionvalue in place of the currency but because Microsoft Excel is equipped for accounting, you can safely

    take advantage of the currency type. When using currency rightly, its number presents the characterspecified in Control Panel. For US English, such a character is $.

    Constants

    A constant is a value that does not change. The constants you will be using in your expressions havealready been created and are built-in Microsoft Excel. Normally, Visual Basic for Applications (VBA),the version of Microsoft Visual Basic that ships with Microsoft Excel also provides many constants. Just

    http://www.functionx.com/excel/index.htmhttp://www.functionx.com/excel/index.htm
  • 7/28/2019 Oracle Excel Part 2

    2/18

    in case you are aware of them, you will not be able to use those constants, as Microsoft Excel does notinherently understand them. For this reason, we will mention here only the constants you can use whenbuilding regular expressions.

    The algebraic numbers you have been using all the time are constants because they never change.

    Examples of constant numbers are 12, 0, 1505, or 88146. Therefore, any number you can think of is aconstant. Every letter of the alphabet is a constant and is always the same. Examples of constant lettersare d, n, c. Some characters on your keyboard represent symbols that are neither letters nor digits. Theseare constants too. Examples are &, |, @, or !

    In Boolean algebra, something is considered True when it holds a value. The value is also considered as or Yes. By contrast, any other value is considered False, 0, or No.

    When a field holds a value, the value would be considered using the comparison operators we will learn.

    Operands and Operators

    The values we have used so far were provided in cells of a spreadsheet. In some cases, you will need todisplay a value that is a combination of other values. For example, you may need to combine a first nameto a last name to create a full name. In another case, to calculate an employees weekly salary, you mayneed to use the value of a salary and multiply it with a number of hours worked in a week. Most, if notall, of these expressions use what we call operators and operand.

    An operation is a technique of using a value or the contents of a cell, or to combine two or more values ocontents of cells to either modify an existing value or to produce a new value. Based on this, to performan operation, you need at least one value or the contents of one cell and one symbol. A value involved inan operation is called an operand. A symbol involved in an operation is called an operator.

    Creating and Using an Expression

    Introduction

    When using a worksheet, an expression is entered in a cell and we will see various types of expressions.As done with the other values we have used so far, to create an expression, you first click a cell. If youknow the expression you want to use, you can type it either in the cell or in the Formula Bar. In mostcases, after typing the expression, you can press Enter (or Tab). In some other cases, as we will see, youcan click another cell whose value will complete the expression.

    To create an expression, you will use some constants values such as numbers or strings, the operators weare going to study, the names of cells, the names of groups of cells, and sometimes the functions:

    To use a constant value, type it in the right place To use a cell, you can type its name. Here is an example:

  • 7/28/2019 Oracle Excel Part 2

    3/18

    To use a cell, after starting the expression, click the cell you want to involve. When a cell has

    been clicked, its blue borders blink. Here is an example:

    After clicking the cell, you can continue creating the expression. At any time when needed, youcan type another name of a cell or you can click any other cell you need. Here is an example:

    After typing and/selecting the cells, click the Enter button or press Enter to end the expression To use a function, we will learn how to, when we get to the functions

    After creating the expression, the value of the cell would represented the expression. When you click it,the Formula Bar would display the expression. Here is an example:

    The Assignment Operator =

  • 7/28/2019 Oracle Excel Part 2

    4/18

    In order to display a value in a cell, it must be preceded with the assignment operator, which is =. Thesyntax you would use is:

    =ValueOrExpression

    The operand on the right side of the assignment operator is referred to as the right value or RValue. It cabe a known value or a reference to another cell.

    There are two main ways we will use the assignment operator:

    Imagine you already have a cell such as B12 and you want to display its value in another cell sucas A4. In A4, you can type =B12 and press Enter. The contents of B12 would be provided to, anddisplayed in, A4

    In some other operations and functions we will learn, you can use the = operator inside of theexpression or function to perform another, intermediary operation, such as a comparison

    Unary Operators

    A unary operator is one that uses only one operand. An operator is referred to as binary if it operates ontwo operands.

    The Positive Unary Operator +

    Algebra uses a type of ruler to classify numbers. This fictitious ruler has a middle position of zero. Thenumbers on the left side of the 0 are considered negative while the numbers on the right side of the 0constant are considered positive:

    - -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 +

    0

    - -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 +

    A value on the right side of 0 is considered positive. To express that a number is positive, you can write + sign to its left. Examples are +4, +228, and +90335. In this case the + symbol is called a unary operatobecause it acts on only one operand. The positive unary operator, when used, must be positioned to theleft side of its operand.

    As a mathematical convention, when a value is positive, you dont need to express it with the + operator

    Just writing the number without any symbol signifies that the number is positive. Therefore, the numbers+4, +228, and +90335 can be, and are better, expressed as 4, 228, or 90335. Because the value does notdisplay a sign, it is referred as unsigned.

    The Negative Unary Operator -

    In order to express any number on the left side of 0, it must be appended with a sign, namely the -symbol. Examples are -12, -448, and -32706. A value accompanied by - is referred to as negative. The -

  • 7/28/2019 Oracle Excel Part 2

    5/18

    sign must be typed on the left side of the number it is used to negate.

    Remember that if a number doesnt have a sign, it is considered positive. Therefore, whenever a number

    is negative, it must have a - sign. In the same way, if you want to change a value from positive tonegative, you can just add a - sign to its left. In the same way, if you want to negate the value of a cell, an

    expression, or a function, you can type theoperator on its left.

    The Double Quotes: ""

    Double-quotes are used to enclose a string. As we reviewed earlier, a string can be an empty space, onecharacter, or a group of characters. Such a string must be considered as is. Therefore, to include a strin

    in an expression, put it in double-quotes. Examples are , "@", "Hermano", or "Rancho Cordova ".

    The String Concatenator: &

    The & operator is used to append two strings, the contents of two cells, or expressions. This is considered

    as concatenating them. For example, it could allow you to concatenate a first name and a last name,producing a full name. The general syntax of the concatenation operator is expressed as:

    Value1 & Value2

    To display a concatenated expression, use the assignment operator on the left of the string. For example,imagine you want to concatenate Juan to Marcus and display the resulting string in cell C5. In C5, youwould type =Juan & Markus and press Enter. The result would be JuanMarkus.

    To concatenate more than two expressions, you can use as many & operators between any twoexpressions as necessary. For example, to add an empty space in the above string, in cell C5, you would

    type =Juan & & Markus

    In the same way, you can concatenate the contents of various cells.

    The Addition: +

    The addition is used to add one value or expression to another. It is performed using the + symbol and itssyntax is:

    Value1 + Value2

    The addition allows you to add two numbers such as 12 + 548 or 5004.25 + 7.63

    After performing the addition, you get a result. You can display such a result in a cell or use it as anintermediary variable in an expression. For example, to add 242.48 to 95.05 and display the result in cellC6, in C6, you would type =242.48 + 95.05 and press Enter.

    Practical Learning: Adding Cells Values

  • 7/28/2019 Oracle Excel Part 2

    6/18

    1. Start Microsoft Excel2. Open the CPAR Repair Orders1.xlsx workbook and, if necessary, click the Repair Order tab3. Click Cell J31 and type =4. Click Cell J16 and type +5.

    Click Cell J17 and type +6. Click Cell J18 and type +

    7. Click Cell J19 and type +8. Click Cell J20 and type +9. Click Cell J21

    10.On the Formula Bar, click the Enter button11.Click Cell J32 and type =12.Click Cell J24 and type +13.Click Cell J25 and type +14.Click Cell J26 and type +15.Click Cell J27 and type +16.Click Cell J28 and type +

  • 7/28/2019 Oracle Excel Part 2

    7/18

    17.Click Cell J29 and, on the Formula Bar, click the Enter button18.Save the workbook

    The Subtraction: -

    The subtraction is performed by retrieving one value from another value. This is done using the - symbolThe syntax used is:

    Value1 - Value2

    The value of Value1 is subtracted from the value of Value2. After performing the operation, a new valueresults. This result can be used in any way you want. For example, you can display it in a cell using theassignment operator as follows:

    = Value1 - Value2

    The Multiplication: *

    The multiplication allows adding one value to itself a certain number of times, set by the second value.The multiplication is performed with the * sign which is typed with Shift + 8. Here is an example:

    Value1 * Value2

    During the operation, Value1 is repeatedly added to itself, Value2 times. The result can be assigned toanother value or displayed in a control as follows:

    = Value1 * Value2

    Practical Learning: Multiplying Cells Values

    1. The CPAR Repair Orders.xlsx workbook should still be opened and the Repair Order sheet activeClick Cell J16

    2. Type =H16*I16 and notice that the cells involved are selected

    3. On the Formula Bar, click the Enter button4. Position the mouse on the button in the lower-right corner of the selected cell until the mouse

  • 7/28/2019 Oracle Excel Part 2

    8/18

    cursor becomes a +

    5. To use AutoFill, click and drag down to Cell J21

    6. Release the mouse7. Select Cells J16:J218. Right-click the selection and click Format Cells9. Click the Border property page and change it as follows:

  • 7/28/2019 Oracle Excel Part 2

    9/18

    10.Click OK11.Save the workbook

    The Division: /

    The division is used to get the fraction of one number in terms of another. For example, to divide aValue1 if Value2 pieces, you would use a syntax as:

    Value1 / Value2

    After performing the operation, you get a new result you can use as you see fit. You can display in a cellor involve it in an expression.

    RTHS - Calculate the mean grade of each course (See Lesson 11)

    The Exponentiation: ^

    Exponentiation is the ability to raise a number to the power of another number. This operation is

  • 7/28/2019 Oracle Excel Part 2

    10/18

    performed using the ^ operator (Shift + 6). It uses the following mathematical formula:

    yx

    The operation is performed as y^x and means the same thing. Either or both y and x can be values or

    expressions, but they must carry valid values that can be evaluated.

    When the operation is performed, the value of y is raised to the power of x. You can display the result ofsuch an operation in a cell using the assignment operator as follows:

    =y^x

    You can also use the operation in an expression.

    The Parentheses Operators: ()

    Parentheses are used to create sections in an expression. This regularly occurs when more than oneoperator is used in an operation. Consider the following expression typed in cell F2 as =8 + 3 * 5. Theresult of this operation depends on whether you want to add 8 to 3 then multiply the result by 5 or youwant to multiply 3 by 5 and then add the result to 8.

    Parentheses allow you to specify which operation should be performed first in a multi-operator operationIn our example, if you want to add 8 to 3 first and use the result to multiply it by 5, in the cell, you wouldwrite =(8 + 3) * 5. This would produce 55. On the other hand, if you want to multiply 3 by 5 first thenadd the result to 8, you would write 8 + (3 * 5). This would produce 23.

    As you can see, results are different when parentheses are used on an operation that involves variousoperators. This concept is based on a theory called operator precedence. This theory manages whichoperation would execute before which one; but parentheses allow you to control the sequence of theseoperations.

    Practical Learning: Using the Parentheses

    1. The CPAR Repair Orders.xlsx workbook should still be opened and the Repair Ordersheet active.Click Cell J34 and type =(

    2. Click Cell J31 and type +3. Click Cell J32 and type )*

  • 7/28/2019 Oracle Excel Part 2

    11/18

    4. Click Cell J33

    5. On the Formula Bar, click the Enter button6. Click Cell J35 and type =((7. Click Cell J31 and type +8. Click Cell J32 and type )*9. Click Cell J33 and type )+10.Click Cell J31 and type +11.Click Cell J32

    12.On the Formula Bar, click the Enter button13.Save the workbook

  • 7/28/2019 Oracle Excel Part 2

    12/18

    14.Create an order as test

    Cells, Worksheets, and Workbooks in Expressions

  • 7/28/2019 Oracle Excel Part 2

    13/18

    Introduction

    So far in our expressions, we were selecting cells to combine their values to the operators and all thecells we used belonged to the same worksheet. In a typical workbook, you use various worksheet.

    Sometimes you will want want to a value stored in a cell of a separate worksheet and want to involvethe value of that cell in the expression. Of course you can copy the value and paste it where needed.The problem is, when/if that value changes, you would have to change it in your expression. Insteadof memorizing the value, you can create an expression that would directly use the value in its cell.

    Using Various Worksheets in an Expression

    In Microsoft Excel, yon can create an expression that involves cells of two or more differentworksheets. To proceed, in the cell where the expression will appear, type the assignment operator"=". If you know the name of the worksheet where the other cell is located, type that name. If thename of the worksheet is in more than one word, include it in single-quotes. If the name is in one

    word, you can omit the single-quotes. After the name of the worksheet, type the ! operator. If youwant to use one cell, type its name. If you want to use a range of cells, type that range. If you want touse different non-adjacent cells, for each cell you want to use, type the name of the worksheetfollowed by ! and the name of the cell.

    Instead of remembering the names of the worksheets and their cells, and as we have done so far withcells, you can start an expression with the = operator. Then, when you need a cell located in anotherworksheet, click the tab of that worksheet and select the cell. Microsoft Excel would take care of thenames behind the scenes. When you end the expression, you will be taken back to the worksheetwhere you were working.

    Practical Learning: Using Various Worksheets in an Expression

    1. Open the CPAR - Accounting Records.xlsx workbook and click the Income Statement tab2. Click Cell J7 and type =3. Click the Transaction Analysis tab4. Click Cell M11 and type +5. Still in the Transaction Analysis tab, click Cell M12 and press Enter6. Back in the Income Statement sheet, click Cell H9 and type =-7. Click the Transaction Analysis tab8. Click Cell M17 and press Enter9. Back in the Income Statement sheet, click Cell H10 and type =-10.Click the Transaction Analysis tab11.Click Cell M18 and press Enter12.Back in the Income Statement sheet, click Cell H11 and type =-13.Click the Transaction Analysis tab14.Click Cell M19 and press Enter15.Back in the Income Statement sheet, click Cell H12 and type =-16.Click the Transaction Analysis tab17.Click Cell M10 and press Enter

  • 7/28/2019 Oracle Excel Part 2

    14/18

    18.Observe the values in Cells H10, J13, and J14 of the Income Statement sheet.Click the Transaction Analysis tab

    19.In Cell C18, type -2,890 and press Enter20.In Cell M18, type -420 and press Enter21.Click the Income Statement tab and notice that the value in Cell H10 has been updated, so

    have the values of Cells J13 and J1422.Save the workbook

    Using Various Workbooks in an Expression

    You may have one (or more) value(s) stored in the cell(s) of a (different) worksheet(s) and theworksheet(s) belong(s) to a different (or various) workbook(s). To use such a values, you could copyit and paste it in the cell that holds the expression you are creating. As mentioned for the worksheet, ifthat value changes, you would have to manually update the expression. Fortunately, you can create anexpression that involves various workbooks and link them so that, when the value of an involved cellchanges, the result of the expression would be automatically updated.

    To involve the cell of a different workbook in an expression, start with the = operator. Type the name

    of the workbook as a file and, because it is a file, include its extension. Because the name of theworkbook includes a period, you must start that name with the left square bracket "[" and you mustend with the right square bracket "]". Just after the right square bracket, type the name of theworksheet where the cell is located. This name, whether the name of the worksheet is in one or morewords, don't include it in single-quotes. Instead, the combination of the name of the workbook and thename of the worksheet must be included in single-quotes. After the the combination of the name ofthe workbook and the name of the worksheet, type the ! operator. As reviewed for the worksheet, the

  • 7/28/2019 Oracle Excel Part 2

    15/18

    ! is followed by the name of the cell.

    As done for the cells of one worksheet or a cell in a different worksheet, after starting the expression,you can access the other workbook and click the desired cell. If you use this technique (as opposed totyping the names), Microsoft Excel would start the name of the cell with $, followed by the letter-

    name of the cell, followed by $, and followed by the number of the row.

    Practical Learning: Using Various Workbooks in an Expression

    1. On the Ribbon, click View2. In the Window section, click View Side by Side.

    In the Window section of the Ribbon, click Switch Windows. If CPAR AccountingRecords.xlsx does not have a check mark, then click it

    3. In the CPAR Accounting Records.xlsx workbook, click the Transaction Analysis tab4. On October 13, 2008, the company fixed a car for a customer. We don't remember how

    much was paid. We will get the value from the Repair Orders worksheet and put it in the

    Transaction Analysis worksheet. We will also update the income satement.In the Transaction Analysis worksheet, click Cell C20 and type =

    5. In the Window section of the Ribbon, click Switch Windows and click CPAR RepairOrders.xlsx

    6. In the worksheet, scroll down and click Cell J35

    7. Press Enter8. In the Transaction Analysis worksheet, click Cell M20 and type =9. In the Window section of the Ribbon, click Switch Windows and click CPAR Repair

    Orders.xlsx

  • 7/28/2019 Oracle Excel Part 2

    16/18

    10.In the worksheet, scroll down and click Cell J35 and press Enter11.Access the CPAR Accounting Records.xlsx workbook and click the Income Statement

    worksheet12.Click Cell J713.In the Formula Bar, click the expression and press End14.

    Type +15.In the CPAR Accounting Records.xlsx workbook, click the Transaction Analysis tab

    16.Click Cell M20 and press Enter

    17.In the Window section of the Ribbon, click Switch Windows and click CPAR RepairOrders.xlsx

    18.In the worksheet, click Cell H17, type 45.35 and press Enter19.Notice that the total of the invoice has changed.

    Access the CPAR Accounting Records.xlsx workbook and check that the values havebeen updated

  • 7/28/2019 Oracle Excel Part 2

    17/18

    20.Save both workbooks

  • 7/28/2019 Oracle Excel Part 2

    18/18