+ Reply to Thread
Results 1 to 16 of 16

for nerds and wannabes: why =OFFSET(A1,0,0) is bad

  1. #1
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Harlan Grove and Charles Williams are having a discussion on volatility. OFFSET vs INDEX
    Over at Smurf on Spreadsheets.

    Nerd alert.

    enjoy

    http://smurfonspreadsheets.wordpress...05/offset-wtf/

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Hi teylyn,
    What your take on the indirect() function?
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    lol

    Thanks Teylyn - this wannabe is in!
    I haven't seen a "live" debate of Harlan's but I've read some of his... (we can definitely say knowledgeable & also, hmmm... "forthright views") in comments/threads.

    Rob
    Last edited by broro183; 01-10-2010 at 03:40 PM. Reason: clarity?
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    What your take on the indirect() function?
    I'm still learning. But what I've learned so far:

    - avoid volatile functions if you can.
    - Sometimes a longer formula can be more efficient than a shorter one with volatile functions. It's not about how short your formula is. It's about how fast it is.
    - sometimes you can't avoid volatile functions
    - sometimes volatile functions are just the easy way out. Work harder.
    - try to develop the non-volatile alternative and become familiar with it
    - if you tend to use volatile functions in small workbooks, where speed is not an issue, you're more likely to also use them in big workbooks where they may bring the house down.
    - if you see one of my solutions commented and improved on by DonkeyOte, study DO's version and learn from it. Like I try to do.
    - It may take a while, but it can be done. I'm sure.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    if you tend to use volatile functions in small workbooks, where speed is not an issue, you're more likely to also use them in big workbooks where they may bring the house down
    now the thing is when?
    i use loads of workbooks for stuff but they never get that big(when they do i archive and start again!),i avoid volatility when i can but sometimes its just easier. a diference of a couple of seconds in a workbook calculating doesnt matter to me.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    mdw, when you read through the blog post where Harlan Grove and Charles Williams post their insights, you can see that they discuss 20MB files with dozens of columns and thousands of rows.

    That's where volatile functions will make a difference to the worse.

    DonkeyOte tried to make it clear to me that if you get into the habit of favouring volatile functions in small files, just because they're easier to construct and use, you may develop a habit and continue to uses them, even when the files grow so big that a non-volatile alternative would make a lot of difference.

    Even when posting answers here, we often only see a small data sample and don't know how big the OP's original file may actually be. So it would be better to develop the most efficient solution from a speed perspective rather than the convenience side.

    I know that every situation is different, and that solutions also often need to be tailored to suit the skills and understanding of the OP, but, hey, if we can teach them to fish ....?

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Yes, I agree, if we can teach them to fish, let's do it

    I learned how to create non-volatile dynamic named ranges using Index late last year from Roger Govier's tutorial (http://www.contextures.com/xlNames03.html). BUT I still occasionally have difficulty wrapping my head around this approach & even knowing the Index approach, my previous habit of...
    [alt + i + n + d], "dynPTSrcRng", [tab], [tab], "=offset(..."
    still exists & I usually find myself 1/2 way through typing the offset formulae before I stop myself!
    (Edit: at work in 2003)


    Rob
    Last edited by broro183; 01-10-2010 at 05:37 PM.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    I've often wondered re: use of INDEX versus OFFSET for DNR's in the past and would confess I'm still not entirely clear on the subject having never really got a definitive answer on it in the past.
    My "impression" was/is that Names are Evaluated when the formulae using them are themselves Evaluated - hence why an overuse of Names can lead to detrimental impact on performance.
    On that basis I have always presumed that it is in fact the Volatile nature of the formulae referring to the Names that is of primary concern rather than the Name definition itself... needless to say I don't know how accurate that assumption is !
    Thinking again now - I guess things become Volatile by association... that would make most sense.

    Quoting Charles Williams' site:

    Quote Originally Posted by DecisionModels
    The benefit of this [DNR] (apart from the fact that you don’t have to change all your formulae) is that Excel then only has to calculate using exactly the right number of rows and columns. However there is a performance hit if you use a lot of Dynamic Ranges. The main performance hit is because OFFSET is a volatile function and therefore is always recalculated,...
    Quote Originally Posted by DecisionModels
    Circumstances causing a name to be evaluated.
    The circumstances causing a name to be evaluated are not the same as a formula in a cell.

    A name seems to only be evaluated when a formula that refers to it is evaluated.
    A name is evaluated every time a formula that refers to it is evaluated, so that using a name in multiple formulae can cause the name to be evaluated multiple times.
    Names that are NOT referred to by any formula are not calculated even by a full calculation (Ctrl/Alt/F9).
    Regardless, it would seem based on general DNR approaches adopted/illustrated by the formula gurus that OFFSET is the norm.
    I think most agree that INDEX is generally speaking a pretty slow formula (more so with large ranges of course) which if you consider it's (immense) flexibility is not surprising ... I think you could argue INDEX to be the "best value for money" function of all, I would.
    Last edited by DonkeyOte; 01-10-2010 at 06:49 PM.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    ... an overuse of Names can lead to detrimental impact on performance
    Assuming that's true (and they surely carry some overhead), IMO it's a pretty good tradeoff for understandability and maintainability.
    It would seem based on general DNR approaches adopted/illustrated by the formula gurus that OFFSET is the norm.
    Agree, and that surprises me a little.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Most interesting bit for me was this:
    using INDEX as the second part of a range argument (A$2:INDEX(A$2:A$8,7,)) makes it semi-volatile: it gets recalculated at workbook open time
    which I never knew before.
    Remember what the dormouse said
    Feed your head

  11. #11
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    R, what's your take on use of OFFSET in Names ?

    It seems that the evaluation of the Name must be Volatile yet why then recommend use of OFFSET in DNRs for use with SUMPRODUCT ?

    Let's assume I have 3000 rows of data - ie cells populated are A1:B3000 - remaining cells are blank - my range will expand over time and I need to ensure I encompass all data.

    Option 1:

    =SUMPRODUCT(--(A1:A10000="a"),--(B1:B10000="b"))

    Option 2:

    I have 2 OFFSET based DNR's setup that restrict my range to just the 3000 rows thereby reducing the number of cells "iterated" in the SUMPRODUCT, ie:

    =SUMPRODUCT(--(DNR1="a"),--(DNR2="b"))

    If the Name is Volatile in it's own right then by association the SUMPRODUCT would become Volatile too, no ? I would have thus assumed that calculating 20000 cells "as and when" required would be better than calculating 6000 cells at every volatile action.

    I would dearly love to get to the bottom of this.

    (And I agree with Rob that use of INDEX over OFFSET would obviously remove the Volatility in the Name but that's not my question here... rather the Q is concerned with the (prevalent) use of OFFSET full stop)
    Last edited by DonkeyOte; 01-11-2010 at 07:38 AM. Reason: typos

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    I try to avoid using OFFSET ever in names, for exactly the reason you specify. Ignoring the fact that you should rethink a worksheet with thousands of SUMPRODUCT formulas, the performance using OFFSET in a DNR will be horrible when working with any open workbook, even if you are referring to a single cell for the COUNT/COUNTA part of the offset.
    For smaller workbooks, it's probably not too bad, but I still wouldn't recommend it.

  13. #13
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    My position is with shg, he brings in a very important statement:

    understandability and maintainability
    goes first.

    I have never run into performance issues (yet), but I'll follow this thread as I like this discussion. Previous post (and even Teylyn's link) are mainly based on assumptions.

    "INDEX() became non-volatile in Excel 97", I do not see why OFFSET is treated differently?

    And what about Conditional Formatting. This seem to be even worst as these re-calculate all CF-cells at any screenupdate (regardless of calculation in AUTO/MAN mode).
    Last edited by rwgrietveld; 01-11-2010 at 08:58 AM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  14. #14
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Romperstomper,

    What is then your alternative to
    Please Login or Register  to view this content.
    Would that be
    Please Login or Register  to view this content.
    and if you know the # of rows will never exceed 20000, would it make a big difference to use
    Sheet1!A1:A20000 then Sheet1!A:A ?

  15. #15
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Quote Originally Posted by rwgrietveld View Post
    Would that be
    Please Login or Register  to view this content.
    Yes, but I would do the COUNTA part in a cell and refer to that.
    and if you know the # of rows will never exceed 20000, would it make a big difference to use
    Sheet1!A1:A20000 then Sheet1!A:A ?
    I doubt it, and I am always extremely reluctant to ever specify a number of rows/columns if I don't have to. Especially if someone tells me it will never be exceeded...

    Oh, and people who use a lot of CF should be slapped silly (or sillier, anyway), IMO.

  16. #16
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: for nerds and wannabes: why =OFFSET(A1,0,0) is bad

    Here's a related link
    http://www.dailydoseofexcel.com/arch...o-more-offset/
    In it they talk about the fact it's the recalculation of "COUNTA" that takes up all the time and not the OFFSET but it would seem to me that, in most cases, you will be using the OFFSET in collusion with other functions so stay away from it. I guess if you're just using OFFSET or just using INDEX, there's little difference.

    I am still struggling with keeping OFFSET out of my defined names. I just learned how to use the INDEX to define two dimensional ranges as one would get with OFFSET.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1