2.63 FAQ-623 How to find the minimum or maximum value in a dataset and the corresponding x value and index number?

Last Update: 7/13/2018

From Status Bar

When you highlight a column, multiple columns or a range of data in a worksheet, basic statistics of the selection shows on the Status bar located at the bottom of the Origin workspace.

By default Min and Max don't show. You can right click on Status bar and check Min, Max, etc. You can also right click on Status bar and Copy Statistics.

For more information see The Status Bar.

By Statistics on Columns/Statistics on Rows Tool

If the dataset is in a column or row, you can report the statistics and retrieve the minimum or maximum value. To bring up these tools, select Statistics:Descriptive Statistics:Statistics on Columns/Statistics on Rows. In either dialog, you will find the check boxes for Minimum and Maximum under branch Quantities to Compute >> Quantities.


* The Statistics on Columns Dialog Box.
* The Statistics on Rows Dialog Box.

Using LabTalk Functions

The following LabTalk functions(max() and min()) are provided for finding the maximum and minimum, the function list() finds the index number, and the function xvalue() finds the corresponding xvalue from a given index number. You can run the LabTalk script below in the Script Window (highlight one of the provided scripts below and press Enter):

To find the maximum and minimum in column B: 
      bMax = max(col(B));
      bMin = min(col(B));

To find the corresponding index number:
      maxIndex = list(max(col(B)),col(B));
      minIndex = list(min(col(B)),col(B)); 

To find the corresponding xvalue: 
  1) Find corresponding value from x column:     
  2) Find corresponding value from a different column C:
      v1 = col(C)[list(max(col(B)),col(B))];
      v2 = col(C)[list(min(col(B)),col(B))];
      v3 = Table(col(B), col(C), Max(col(B)))
      v4 = Table(col(B), col(C), Min(col(B)))

Using Column Formula

You can use LabTalk functions in F(x)= cell or Set Values) dialog box to find the maximum and minimum value, index number, the corresponding xvalue, or corresponding value in any column.

Since Origin 2017, Origin support spreadsheet cell notation in column formula so you can directly use B intead of col(B).

E.g. add a new column in worksheet. Input the following into the F(x) cell or its Set Values dialog box:

  • To find the maximum and minimum in column B:
  • To find the corresponding row index number of max or min value in column B: If there are duplicate max/min values in column B, it returns the row index number of first occurance of max/min value.
  • To find the corresponding x value of max or min value in column B, suppose B is an Y column.
  • To find the corresponding value in column C on the same row where max or min value of Column B is found:
    Table(B, C, Max(B))
    Table(B, C, Min(B))

Note: You will need to input col(B) rather than B for Origin 2016 and older.

Keywords:Descriptive Statistics, Status Bar, Statistics on Columns, Statistics on Rows, Index Value, Corresponding Value