Intro to SCAN

It took me years to start using more advanced functions like this. Don’t wait that long. 🤣🤣

MORE AI CONTENT COMING SOON

Hey y’all,

I’ve been throwing more of my time into AI tooling this year, and I will be sharing my progress with you soon. Nothing has increased my understanding of and productivity with spreadsheets, automations, and software in general quite like the AI tooling available right now.

I’m using all the frontier models, but Claude is going to be my primary focus.

I’ve started making more content already on the YouTube channel - check it out here if you aren’t subscribed yet.

It’s the best at coding and technical tasks which is where I think the most gains are going to be had in this space.

My focus is on implementing AI in businesses.

Hit reply and let me know how your business is, isn’t, or should be using AI today.

The Google Sheets Function That Replaces Your Running Total Column

I used SUM to solve this problem for years until I found out about SCAN.

Here’s the official definition of SCAN:

This function scans an array and produces intermediate values by application of a LAMBDA function to each value. Returns an array of the intermediate values obtained at each step.

Your Balance Sheet Shouldn't Be This Fragile

I use a running total column in my most popular spreadsheet, which is a personal finance app.

You need a running balance that updates automatically as new rows appear. I've always just had a balance column with a formula that I copy all the way down.

It works, but it's not very elegant. And there's a better way: to write one formula in the top cell. A little help from ARRAYFORMULA and you don’t have to copy anything else down.

What SCAN Actually Does

SCAN walks through an array and accumulates a result, step by step, like a running total on autopilot. It takes three arguments: a starting value, an array to process, and a LAMBDA that defines what happens at each step.

Don't be afraid of LAMBDA. I was for a long time, but it's very powerful and easy to use once you wrap your head around it.

It's basically just a way to define a formula inside of a formula.

Here's the formula that replaces an entire column of manual calculations:

=ARRAYFORMULA(
  IF(Table1[amount],
    start + 
    SCAN(G1,
      IF(Table1[category]="income", Table1[amount], -Table1[amount]),
      LAMBDA(a, x, a+x)),
  ""))

Here’s how it works 👇

The Inner Logic

IF(Table1[amount], ..., "")
The outer wrapper keeps empty rows clean. No amount? No balance displayed.

IF(Table1[category]="income", Table1[amount], -Table1[amount])
This is your transformation layer. Income stays positive. Everything else flips negative. You're converting a raw transaction log into a signed array before SCAN ever touches it.

SCAN(G1, ..., LAMBDA(a, x, a+x))
G1 is your starting balance (maybe zero, maybe last month's closing balance). SCAN then walks through each signed amount, adding it to the accumulator. The a is the running total so far. The x is the current value.

start + SCAN(...)
Offsets everything by your starting value, so your running balance begins exactly where you need it.

Why This Beats the Drag-Down Approach

One formula, infinite rows. Because it's wrapped in ARRAYFORMULA, it spills results down automatically. New transaction? The balance updates. No dragging required.

Nothing to break. Delete a row and the formula recalculates. Insert a row and it adapts. There's no chain of cell references waiting to snap.

Readable logic. I've been switching to ARRAYFORMULA in all of my spreadsheets lately so that I can have single points of failure instead of tons of different formulas littered throughout each sheet.

Where Else SCAN Shines

Running balances are the obvious use case, but SCAN is quietly powerful anywhere you need cumulative logic:

  • Inventory tracking: Start with stock on hand, subtract orders, add restocks. One formula.

  • Goal progress: Accumulate daily outputs against a monthly target.

  • Cumulative revenue: Show month-to-date or year-to-date totals that update in real time.

  • Sequential numbering with conditions: Increment a counter only when a condition is met.

The pattern is always the same: starting value → array → LAMBDA that defines the accumulation rule.

NEXT STEPS
Whenever you’re ready, here’s how I can help:

  1. Work with me
    I’m available for consulting projects. Reach out and let’s chat.

  2. Business tech stack
    Some of my recommendations for software and tools.

  3. Personal budget tool
    As a subscriber, you get a discount on my personal finance system.

  4. YouTube
    If you aren’t subscribed yet, come on over to the YouTube channel where all the spreadsheet, automation and productivity tutorials live.

TOOLS
Make life easier

  • Coefficient - Live spreadsheet connections to 60+ business systems

  • Lido - Automate your spreadsheets; accurately extract date from PDFs

  • TransactionPro - quickly import, export or delete data in Quickbooks

  • beehiiv - my choice for a newsletter operating system

  • Carrd - free one-page website builder

  • Transistor - my favorite podcast host

Happy Spreadsheeting!

Enjoyed this issue?
Subscribe below or Leave a testimonial

<iframe src="https://embeds.beehiiv.com/eab8502a-f9ab-4d3f-abc8-30b1abb520a9?slim=true" data-test-id="beehiiv-embed" height="52" frameborder="0" style="margin: 0; border-radius: 0px !important; background-color: transparent;"></iframe>

Cheers, Eamonn
Connect on LinkedIn, YouTube & Twitter.

Reply

Avatar

or to participate

Recommended for you