+ Reply to Thread
Results 1 to 22 of 22

Calcuate difference in one column based on value change in another column

Hybrid View

  1. #1
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Calcuate difference in one column based on value change in another column

    Using the data you posted and taking the formula in cell W26, this part:

    LOOKUP(1,0/V$2:V25,U$3:U26)

    which, putting in the entries from V2:V25, is:

    LOOKUP(1,0/{1;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0},U$3:U26)

    and, after reciprocation with zero:

    LOOKUP(1,{0;0;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!},U$3:U26)

    The point being that, any zeroes within that range have now been rendered as errors. As such, they will be ignored by LOOKUP (one of its useful properties), which was precisely the reason for the prior reciprocation.

    And, providing the lookup_vector is sorted (which, since it contains nothing but zeroes (recall that we ignore the errors), can certainly be said for that array in this instance), then, if the lookup_value is greater than all values within the lookup_vector (the choice of 1 here is therefore always sufficient, though any other value >0 would also suffice), the entry corresponding to the last numerical value within the range is returned. Here that is equivalent to the last zero within that array, highlighted in the above.

    Regards
    Last edited by XOR LX; 08-25-2016 at 10:07 AM.
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  2. #2
    Registered User
    Join Date
    08-25-2016
    Location
    USA
    MS-Off Ver
    14.0.7172.5000 (32-bit)
    Posts
    96

    Re: Calcuate difference in one column based on value change in another column

    Okay going back to your explanation here, I understand
    how anything that isn't a natural number gets reduced
    to #DIV/0 (error) and therefore left out of the array.
    It will therefore use the row corresponding to the
    number of 1's (my columns are either 0 or 1).

    So let's look at my attached spreadsheet that was
    calculated correctly in AI63 as

    =IF(AND(COUNTIF(AH62,0),AH63=1),LOOKUP(1,0/AH$2:AH62,$B$3:$B3940)-$B63,"")

    So let's see... it should have done B61-B63 (it did).

    But how did it get B61? AH2:AH56 are all blank so
    those are ignored, right? AH57:AH58 are 0s, which
    become errors upon reciprocation so those are
    ignored. AH59:AH60 are both 1s and then you have
    the 0 in AH61. So if it is looking at the array
    from AH2:AH62 then wouldn't that reduce to just
    two cells: AH2 and AH3? Then it if took the last
    one, AH3, wouldn't it look at the corresponding
    second piece of data which would be B4 (since
    it starts at B3)? B4 would be wrong.

    Thanks,
    Mark



    ---------------------------------------------------------------------------------------------
    Quote Originally Posted by XOR LX View Post
    Using the data you posted and taking the formula in cell W26, this part:

    LOOKUP(1,0/V$2:V25,U$3:U26)

    which, putting in the entries from V2:V25, is:

    LOOKUP(1,0/{1;1;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0},U$3:U26)

    and, after reciprocation with zero:

    LOOKUP(1,{0;0;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!;#DIV/0!},U$3:U26)

    The point being that, any zeroes within that range have now been rendered as errors. As such, they will be ignored by LOOKUP (one of its useful properties), which was precisely the reason for the prior reciprocation.

    And, providing the lookup_vector is sorted (which, since it contains nothing but zeroes (recall that we ignore the errors), can certainly be said for that array in this instance), then, if the lookup_value is greater than all values within the lookup_vector (the choice of 1 here is therefore always sufficient, though any other value >0 would also suffice), the entry corresponding to the last numerical value within the range is returned. Here that is equivalent to the last zero within that array, highlighted in the above.

    Regards
    Attached Images Attached Images

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Calcuate difference in one column based on value change in another column

    Quote Originally Posted by Mark43 View Post
    So let's look at my attached spreadsheet
    Can only see a screenshot, not an attachment?

    Regards

  4. #4
    Registered User
    Join Date
    08-25-2016
    Location
    USA
    MS-Off Ver
    14.0.7172.5000 (32-bit)
    Posts
    96

    Re: Calcuate difference in one column based on value change in another column

    Sorry that's what I meant (screenshot).

    Mark

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 12-16-2015, 05:56 PM
  2. [SOLVED] Need a formula to change cell in column 2 based off of text in column 1
    By bevwalker in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-30-2014, 03:26 PM
  3. Need a formula to calcuate percentage difference between budget $ and actual $
    By meekinslfm in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-06-2014, 09:54 AM
  4. [SOLVED] How to pick name from column based value difference in column B
    By genetist in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-13-2013, 01:34 AM
  5. Change colour in column C based on Column B - future dates
    By kfwiss in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2013, 05:47 AM
  6. Based on Years calcuate Min() and Max() values from another column
    By SunOffice in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-30-2013, 11:14 AM
  7. Replies: 4
    Last Post: 09-05-2012, 01:50 PM

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