4.6.9 Using a Formula to Set Cell ValuesBeginning with version 2018, Origin supports cell-level calculations. Show
Contents
Cell Formula NotationAll cell formulas begin with an equals sign "=": =A1 // returns value in column A, row 1 =A1+B1 // returns total of column A, row 1 and column A, row 2 =mean(A) // returns mean of column A =total(A[1:10]) // returns total of cells A1 through A10 =mean(A1:J10) // returns the mean of cells in the range A1 through J10. =date(A1, "dd.MM.yyyy HH:mm:ss.##") // takes date-time string of specified format in column A row 1, returns Julian day value Edit Mode and Display of Cell FormulasThe worksheet has an Edit Mode (from the menu, Edit: Edit Mode):
Edit Cell Formulas in Formula BarThe Formula Bar introduced in Origin 2021 is an Excel-like bar allowing you to enter cell or column formula/expressions. While it is not necessary to use the Formula Bar to enter cell expressions, it does offer the advantages of function search, interactive range selection and improved visibility of expressions, particularly of long expressions that exceed cell width. You can also define a cell or cells as range variable. To turn on Formula Bar, with a workbook active,
Or
Or,
When your expression is complete, click the check button or press Enter.
Note: inserting data range of a different book is not supported.
Or,
What Can I Enter in Worksheet Cell Formulas?In addition to data references, your cell formula can include variables, operators, functions and constants.
Cell Formula ExamplesCell references in Origin, as in MS Excel, can be relative, absolute or mixed. Prior to Origin 2020, square brackets (e.g. A[1]) were used to make absolute cell references. Now, you can use the MS Excel "$" notation in absolute and mixed cell references. Brackets are still supported but most users will probably prefer the $ notation, especially if they are experienced Excel users.
The following are examples of expressions that can be entered into the cell.
† Excel does not use Julian dates but instead uses a "serial number" system in which "time zero" is either January 1, 1900 (Windows default) or January 1, 1904 (Mac default). For information on converting Excel dates to Origin's Julian-based system, see FAQ-283: How do I convert date data from Excel to Origin? Fore more information, see:
Note: Users should note that in Origin's built-in scripting language LabTalk, the "$" is also used to create or express a string variable. string greeting$ = "Hello"; // creates a string variable named "greeting" and assigns to it, the value "Hello" greeting$ =; // returns "Hello" In the example in row 2 of the table above, two string variables are concatenated using the "+" operator. In this context, the "$" has nothing to do with absolute cell references. If the "$" is at the end of the string, it will be associated with string conversion and not cell references. Another example in which the user might be confused by the "$" string notation: Suppose you want to return a string value "boston" from cell A1: =A1 // returns missing value (--) =A1$ // returns "boston" =upper(A1$) // returns "BOSTON" Another use for string notation: Suppose you want to return a cell value from another book. There are a couple of ways to do this (including the more straightforward [BookName]SheetName!ColNameRowIndex) but you could also use, say, [A1$]SheetName!ColNameRowIndex, where cell A1 contains the name of the source book. If cell A1 contained "Book1" then the string is converted as [Book1]. See, for instance, Extending Formulas that Contain Sheet References. AutocompleteFor Origin 2022, cell formulas, the F(x)= label row and column formulas ( the Set Values dialog) get autocompletion support for LabTalk-supported functions and named ranges. If you do not wish to use the feature, you can disable it for cell/F(x)= and/or column formulas:
User Parameter Row FormulaBeginning with Origin 2019, you can right-click on the column label row headings, Add User Parameters and name and define a formula for the entire row. This is handy for calculating key statistics (e.g. mean, std. deviation) for each column of numbers in a worksheet. The column formula uses the placeholder "This" as a wildcard reference to each column in the worksheet (see next section). Once a row formula has been created, you can edit the Name and Formula by right-clicking on your User Parameter row heading and choosing Edit from the shortcut menu. You can edit cell formulas individually by double-clicking directly into a User Parameter row cell. Referring to Worksheet Columns using "This"As mentioned in the previous section, "This" is a placeholder that is used to refer to the current dataset, i.e. the values in the associated worksheet column. We saw that "This" is used when creating a user parameter row formula and you can use "This" in your own cell and column formulas. If you want to define a user parameter row formula and extend it across the entire row, define a Formula using the procedure outlined above. If you want to add a formula only to some user parameter cells -- you can do the following:
Auto Adjustment of Cell Formulas When Inserting or Deleting Rows or ColumnsInserting or deleting of columns or rows triggers automatic adjustment of column formulas. Extending Formulas Across Rows or Columns
Once you have entered a cell formula into a cell, it is possible to extend the formula to cells in other rows and columns, (1) hovering on the lower-right corner of the formula cell and (2) when the cursor becomes a "+", drag with your mouse to extend down, across or both.
Extending Formulas that Contain Sheet ReferencesNote that when dragging cell formulas that contain sheet references, row and column references auto-adjust while sheet references do not (see following example): This won't be an issue for most users but occasionally, a user wants to reference a particular cell on multiple sheets and when trying to fill a column with values by dragging with the mouse, the sheet reference fails to auto-adjust. While there is no direct method of auto-adjusting sheet references, there is a workaround. This involves filling a worksheet column with the needed sheet names (strings), then using a special syntax to concatenate those strings with a column and row fragment that -- when combined with the sheet string -- forms a complete cell reference. To quickly review, Origin's dataset naming syntax (range notation) allows two ways of referring to the worksheet -- by sheet name or by sheet index. Thus, Sheet1 can be referred to by Sheet1! or simply 1!. Note the exclamation mark (!) which is used in range notation to separate sheet from column[row] (e.g. Sheet1!Col(1)[1] or Sheet1!A[1] or Sheet1!A1). In the above example, we have auto-filled column A with row numbers and column B with sheet names. We can combine references to these cells with a "!Col[row]" fragment that resolves to "1!Col[row]" or "SheetN!Col[row]". The general form of our concatenated string is: ==SheetOrIndex$ + "!ColumnRow" (or "!Column[Row]") Note that your sheet strings will need to be on the same page where you build your auto-adjusting sheet references. Older Methods of Referencing Worksheet Cell ValuesThere are older methods for inserting cell values, variable values and strings into worksheet cells and, in a limited way, these methods will support calculations (e.g.
Limitations to Use of Cell FormulasBeginning with Origin 2018, cell formulas give users a way to perform cell-level calculations incorporating cell values, functions, variables and constants, using a syntax that is similar (but not identical) to MS Excel. Things that are not supported:
When you copy a formula to another cell and the cells in the formula change the cells are known as relative cell references?Relative cell references are basic cell references that adjust and change when copied or when using AutoFill. Example: =SUM(B5:B8), as shown below, changes to =SUM(C5:C8) when copied across to the next cell. Situations arise in which the cell reference must remain the same when copied or when using AutoFill.
Which type of cell references are automatically updated when copied?There are two types of cell references: relative and absolute. Relative and absolute references behave differently when copied and filled to other cells. Relative references change when a formula is copied to another cell. Absolute references, on the other hand, remain constant no matter where they are copied.
Which of the following formulas totals the cells B6 B7 B8 B9 and B10 most efficiently?Q. Which of the following formulas totals the cells B6, B7, B8, B9, and B10 most efficiently? The formula =B6+B7+B8+B9+B10.
How do you edit the formula in a cell so the references to another cell will update when the formula is copied?Select the cell that contains the formula. , select the reference that you want to change. Press F4 to switch between the combinations. The table summarizes how a reference type will updates if a formula containing the reference is copied two cells down and two cells to the right.
|