4.6.9 Using a Formula to Set Cell ValuesUsingFormulaetoSetCellValues
Beginning with version 2018, Origin supports celllevel calculations.
 The cell formula mechanism discussed here is not the only way to do math operations on cell values. Origin has a Set Values feature for doing rowwise math operations on partial or entire columns of data, including multiple columns. Set Values is not only faster  it has such things as syntax coloring and assistance with functions  things that are quite helpful when building complex expressions. Plus, you can define scripts to do such things as conditioning of data before your calculations are performed. For more information, see Set Column Values  Quick Start.

Cell Formula Notation
All 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 datetime string of specified format in column A row 1, returns Julian day value
Edit Mode and Display of Cell Formulas
The worksheet has an Edit Mode (from the menu, Edit: Edit Mode):
 Edit Mode allows for display and easy editing of cell formulas.
 When Edit Mode is toggled off, cell formulas are hidden and instead, the resulting cell value is displayed (note that in this mode, you can also doubleclick on a cell to edit the formula).
 You don't have to toggle Edit Mode on to see the formula behind a particular cell value. When the cell is selected, the formula will display in the lowerleft corner of the Status Bar.

Edit Cell Formulas in Formula Bar
The Formula Bar introduced in Origin 2021 is an Excellike 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.
with a workbook active,
 select menu View: Formula Bar.
Or
click on the cell, then:
 Enter an "=" and type your expression directly;
Or,
 click the button to open the Search and Insert Functions dialog.
 Search for the desired function then doubleclick on it to insert it into Formula Bar.
When your expression is complete, click the check button or press Enter.
 Enter an "=" and enter your expression. Place the cursor at where you want to insert the data range and select the range by
 clicking on a column heading, or
 dragging to select a range of cells.
 When your expression is complete, click the check button or press Enter.
Note: inserting data range of a different book is not supported.
 drag the edge of the Formula Bar to resize it.
Or,
What Can I Enter in Worksheet Cell Formulas?
In addition to data references, your cell formula can include variables, operators, functions and constants.
Data References

Variables

Operators

Functions

Constants






Cell Formula Examples
Cell 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.
 Use "end" or "0" to define the last cell in the column. So, for instance, to enter a cell formula that sums all values of column C, rows 5 to the last row of the column, you could say "=total(C[5:end])" or "=total(C[5:0])".

The following are examples of expressions that can be entered into the cell.
Origin Cell Notation

Excel Notation

Description

=B1  C1

=B1C1

Returns the difference between column B, row 1 and column C, row 1.

=B0  C1

N/A

Returns the difference between the last row of column B (0=last cell), and column C, row 1.

=B1$ + C1$

=B1 & C1

Concatenate strings in column B, row 1 and column C, row 1. See Note at the end of this table.

=text(mean(B1:B10),".2")+" ± "+text(stddev(B1:B10),".4")

=(TEXT(AVERAGE(B1:B10),"0.00") & " ± " & TEXT(STDEV(B1:B10),"0.0000"))

Calculate mean and standard deviation of a range, then round to specified number of decimal places and convert to text. Concatenate, inserting string " ± " (e.g. 0.56 ± 0.2740).

=$B1 + $C1

=$B1 + $C1

Adds the value in column B, row i to and column C, row 1.
This type of expression (using "$") is typically used to copy a formula to other cells by dragging with the mouse. See "Extending Formulas..." below.

=B1  $C$1

=B1  $C$1

Returns the difference between column B, row 1 and column C, row 1. The B1 reference is relative and when dragging to autofill other cells, row reference will increment down rows and column reference will increment across columns. The column $C$1 reference is absolute and will not change when dragging down rows or across columns.
See "Extending Formulas..." below.

=Sheet2!B1  Sheet3!B1

=Sheet2!B1  Sheet3!B1

Returns the difference between Sheet2, column B, row 1 and Sheet3, column B, row 1.

=[Book2]Sheet1!A1  [Book3]Sheet1!A1

=[Book2]Sheet1!A1  [Book3]Sheet1!A1

Returns difference between [Book2]Sheet1!A1 and [Book3]Sheet1!A1.

=[Book2]Sheet1!col(A)[1]  [Book3]Sheet1!col(A)[1]

N/A

Returns difference between [Book2]Sheet1!A1 and [Book3]Sheet1!A1. Alternate column and row syntax.

=total(Sheet2!A1:J10)+total(Sheet1!A1:J10)

=SUM(Sheet2!A1:J10)+SUM(Sheet1!A1:J10)

Totals cells in ranges Sheet2!A1:J10 and Sheet1!A1:J10

=sin(pi*B1)

=SIN(PI()*B1)

Returns the sine of pi * column B, row 1

=date(A1, "dd.MM.yyyy HH:mm:ss.##")

 ^{†}

Origin takes datetime string of specified format and returns Julian day value. Note differences in Origin and Excel behavior.

=today()

=TODAY() ^{‡}

Origin returns the current date as a Julian day value. Note differences in Origin and Excel behavior.

=A1<=98.6? (A198.6): Na()

=IF(A1<98.6, A198.6, NA())

if A1 <= 98.6, return A198.6, otherwise return a missing value (see LabTalk Utility Function, Na()).

=total(A[1:3])

=SUM(A1:A3)

Returns the sum of a column A, row 1 to column A, row 3.

=page.v1*B1

N/A

Returns value of system variable v1 (stored with page) multiplied by value in column B, row 1

=col(A)[D1]*A1

N/A

Returns the value of column A Userparameter 1 multiplied by value in column A, row 1

† 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 Julianbased system, see FAQ283: How do I convert date data from Excel to Origin?
‡ Origin's today() function returns today's date as a Juliandate value while Excel's TODAY() function returns today's date as an Excel serial number.
Fore more information, see:
Note: Users should note that in Origin's builtin 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.

Autocomplete
For Origin 2022, cell formulas, the F(x)= label row and column formulas ( the Set Values dialog) get autocompletion support for LabTalksupported 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:
 Click Preferences: System Variables.
 In an empty Variable cell, type FAC.
 Enter one of the following in the Value cell (values are additive): 0 = turn off autocomplete, 1 = enable for cell formula/F(x)=, 2 = enable for column formula, 3 (default) = enable for cell/F(x)= and column formula.
 Click OK to close the dialog.
User Parameter Row Formula
Beginning with Origin 2019, you can rightclick 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 rightclicking on your User Parameter row heading and choosing Edit from the shortcut menu. You can edit cell formulas individually by doubleclicking 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:
 Create a Userdefined Parameter row.
 In the Userdefined column cell where you want to add a formula, enter your formula using "This" to refer to the data in the current column (e.g.
=max(This) ).
 Click outside the cell to exit celledit mode. A calculated value should display.
 With the cell selected, hover on the lower right corner of the cell then (a) grab the "+" handle and drag with your mouse to extend the calculation to other worksheet columns or (b) doubleclick on the "+" handle to extend the formula to every row cell to the right of the original formula cell.
Note that "This" can also be used in worksheet data cells, as for instance, at the end of a column of data (e.g. "=total(This)"). It cannot be used to represent data in rowwise calculations.
Auto Adjustment of Cell Formulas When Inserting or Deleting Rows or Columns
Inserting or deleting of columns or rows triggers automatic adjustment of column formulas.
Extending Formulas Across Rows or Columns
 Extending a cell formula across many rows and columns can strain system resources and may cause Origin to freeze. In many cases, you can accomplish the same task using more easily using the F(x)= cell or the (equivalent but more powerful) Set Values dialog box.

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 lowerright corner of the formula cell and (2) when the cursor becomes a "+", drag with your mouse to extend down, across or both.
 When you drag a cell formula to autofill other cells, column and row references are adjusted in relative fashion. That is, if you drag "=A1 + B1" from cell C1 to cell D1, the formula in D1 is adjusted and becomes "=B1 + C1". In such instances, cell references are said to be relative.
 To make absolute references to a cell value, place a "$" character before both the column reference and the row reference (e.g. =$A$1). Dragging "=$A$1" to other cells does not adjust the cell reference. It will equal the value in column A, row 1 in every cell to which it is copied (dragged).
 To make mixed references to a cell value, place the "$" character in front of that element  column or row  that you do not want adjusted. For instance, when dragging a formula containing "$A1" to cells in other rows and columns, the column reference "A" will be locked while the row reference "1" will be incremented by one for each successive row.
 You can also use "[i]" to create relative row references: "[i]" is a variable that is recognized as a reference to the current row (i.e. a cell formula of "=B[i]" will return the value in column B, in the same row in which the cell formula appears). The following figure illustrates equivalent forms that will return the same values.

 Rather than dragging to extend a formula down a long column of values, hover over the lower right corner of the first formulacontaining cell and doubleclick on the crosshairs.

Extending Formulas that Contain Sheet References
Note that when dragging cell formulas that contain sheet references, row and column references autoadjust 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 autoadjust. While there is no direct method of autoadjusting 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 autofilled 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 autoadjusting sheet references.
Older Methods of Referencing Worksheet Cell Values
There 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. var://max(col(A))*2 ). Most users will find the newer notation to be much more useful but we point these things out so that the user is aware.
Limitations to Use of Cell Formulas
Beginning with Origin 2018, cell formulas give users a way to perform celllevel 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:
 Importing an MS Excel file will not bring in your Excel formulas. As of Origin 2018 SR0, only calculated values are imported. See Working with Microsoft Excel.
 Cell formulas are not supported in the Long Name, Units, Comments or system Parameters rows of the Column Label Rows portion of the worksheet. They are only supported in Userdefined Parameter rows.
 In Origin, the variable i = row index and the variable j = column index (see System Variables). Formulas incorporating the row index variable i can be extended down a column by dragging (e.g. "=B[i]  C[i]") but formulas that combine multicolumn range references and the variables i or j (e.g. "=total(A[i]:D[i])") are NOT supported.
 There are "@" two system variables that the user should be aware of:
 To disable cell formulas in the current session, open the Script window (Window: Script Window) and type:
@esc=0 <Enter>
 To disable support for Excelstyle notation (cell and column references such as "A1:C10") in the current session, open the Script window (Window: Script Window) and type:
@xlr=0 <Enter>

