Is it possible to avoid re-evaluations in subsequent formula parameter(s) if an evaluation has already been conducted in an earlier parameter?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

This is a general question which I recently started to think about as the size of several of my files are growing rapidly do to huge amounts of data generated by students.

For example, take this simple formula: IF(AVERAGE(A1:C1)>2,AVERAGE(A1:C1),1)

Here, the compiler evaluates AVERAGE(A1:C1) in the first parameter to see if the condition is TRUE or not, and then it re-evaluates the same expression in the second parameter to get the value if TRUE. Of course, in simple cases like this, this is ok, but when there are thousands of complex formulas, then avoiding these re-evaluations will make a big difference in terms of speeding up the file. (right now, in some of my files the delay has reached a couple of seconds every time I make a change.)

I was hoping if there is any way to recycle evaluations from those parameters that have already been checked by the compiler? :biggrin: Thanks for any input!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Current versions of Excel include the Let function; try it.

Let_a.xlsm
ABCD
12464
2
3e
Cell Formulas
RangeFormula
D1D1=LET(a,AVERAGE(A1:C1),IF(a>2,a,1))
 
Upvote 0
Solution
Wow! Yes, that's a phenomenal suggestion!! I'll try it during the coming week, and I feel confident it should help. Thank you. I'll update.
 
Upvote 0
It is working really well, and I can already feel the benefit of LET-based coding. Thanks a gain for the suggestion!
 
Upvote 0
Do you think Excel actually calculates twice? I was always told it only calculates when needed, and assumed it was smart enough to know that an equation is equal to an equation
 
Upvote 0
With the formula the OP posted this part AVERAGE(A1:C1) will calculate twice.
 
Upvote 0
I've not heard that using LET() represents a performance improvement, only in readability. I will believe you once I know more.
 
Upvote 0
I've not heard that using LET() represents a performance improvement
That's the whole point of it, you only need to calculate something once rather than multiple times.
 
Upvote 0
You are correct. Of course, this second part of the OP quesition, of having early cutoff for proofs, is not possible, except maybe with Lambda?
 
Upvote 0

Forum statistics

Threads
1,215,257
Messages
6,123,916
Members
449,133
Latest member
rduffieldc

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top