Find the Running Minimum Value in Google Sheets

Published on

Summary:
Learn how to find running minimum values (cumulative minima) in Google Sheets using non-array formulas like MIN, or array formulas like SCAN and DMIN. This tutorial covers step-by-step methods for stock prices, cumulative minimum logic, and even a legacy approach using DMIN.


Let’s learn how to find running minimum values, also called cumulative minima or cumulative minimum, using array and non-array formulas in Google Sheets.

We can use non-array MIN, or array formulas like DMIN and the new SCAN to calculate cumulative minima in Google Sheets.

If you invest in stocks, you may find these formulas particularly useful.

Using them, you can easily find how far a particular or current price point is from the historical minimum throughout the day.

For example:

I have the share price of an automotive manufacturing company throughout the day in an array (B2:B11) in Google Sheets.

The running minimum values are in C2:C11, and how far off the share price is from the cumulative minima at each point is in D2:D11.

Finding the Running Minimum Value (Cumulative Minima) in Google Sheets

Note: To find cumulative maxima, you can use MAX, DMAX, or SCAN formulas. I have detailed that here: Running Max Values in Google Sheets (Array Formula Included).

What Are the Formulas Used in Cells C2 and D2?

Finding Running Minimum Values (aka Cumulative Minima) in Google Sheets

Here we go!

Cumulative Minimum Using MIN (Non-Array Formula)

In cell C2, insert the following MIN formula and drag it down:

=MIN($B$2:B2)

For cell D2, use:

=B2-C2

And drag it down as well.

SCAN Array Formula to Get Running Minimum Value in Google Sheets

The new SCAN function is the best array solution to get running minimum values in Google Sheets.

We usually use it for running sums, but here we’ll apply it to cumulative minimums. It processes an initial value (accumulator) row by row through the array.

Syntax: SCAN(initial_value, array_or_range, lambda)

Before using SCAN for this, it’s important to understand what cumulative minimum (Cummin) means.

Cummin is simply comparing the current value with the previous minimum and keeping the smaller one.

Cummin Array Formula for C2:

=SCAN(B2, B2:B, LAMBDA(a, v, IF(a <= v, a, v)))

Logic:

  • The initial_value (a) is the first value in the array.
  • In the first row, since a and v are the same, it returns that value.
  • From the second row onwards, it compares the previous minimum (a) with the current value (v) and returns the smaller one.
  • This logical test a <= v continues for every row.

You can also find how far the share price is from the cumulative minima using an array formula:

In D2, insert:

=ArrayFormula(IF(LEN(B2:B), B2:B-C2:C, ))

Legacy Method: Using DMIN for Running Minimum (Before SCAN)

Suppose you have a 10-by-1 vector of share prices in the range B2:B11.

How do you use DMIN to find the running minimum?

Let’s break it down step-by-step:

Logic Behind Finding Cumulative Minima with DMIN

We have a 10-row, 1-column matrix (B2:B11).

We need to transform it into a 10×10 matrix (10 rows × 10 columns) so we can compute the minimum of each column individually.

By doing so, we find the cumulative minimum through an array formula.

Two steps involved:

  1. Transform Data to 10×10 Matrix
  2. Apply DMIN to Each Column

Step 1: Transforming Data

In E1, insert:

=ARRAYFORMULA(TRANSPOSE({B2:B11, IF(SEQUENCE(10, 10) / SEQUENCE(10, 10) + SEQUENCE(1, 10, ROW(A2)-1)<=ROW(A2:A11), TRANSPOSE(B2:B11),)}))

This will create the database for the DMIN operation.

Database Setup for DMIN Test in Google Sheets

Step 2: Cumulative Minimum Using DMIN Array Formula

In C2, use:

=ARRAYFORMULA(DMIN(E1:N11, SEQUENCE(10), {IF(,,); IF(,,)}))
  • The SEQUENCE function generates numbers 1 to 10, corresponding to field IDs in the DMIN database.

Then, replace E1:N11 with the full transformed array formula from Step 1 to make it dynamic.

Final cumulative minima formula:

=ARRAYFORMULA(DMIN(TRANSPOSE({B2:B11, IF(SEQUENCE(10, 10) / SEQUENCE(10, 10) + SEQUENCE(1, 10, ROW(A2)-1)<=ROW(A2:A11), TRANSPOSE(B2:B11),)}), SEQUENCE(10), {IF(,,); IF(,,)}))

Closed vs. Open Ranges

Closed RangesOpen Ranges
B2:B11INDIRECT("B2:B"&MATCH(2,1/(B:B<>""),1))
A2:A11INDIRECT("A2:A"&MATCH(2,1/(B:B<>""),1))
10 (within SEQUENCE)ROWS(INDIRECT("B2:B"&MATCH(2,1/(B:B<>""),1)))

I’ve modified the formula accordingly in my sample sheet below.

Sample Sheet

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

Reset SCAN by Another Column in Google Sheets and Excel

Resetting SCAN function results based on values in another column is a topic of...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

More like this

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.