+ Reply to Thread
Results 1 to 7 of 7

index match excel with negative and positive numbers

  1. #1
    Registered User
    Join Date
    11-11-2021
    Location
    Durban
    MS-Off Ver
    2007
    Posts
    3

    index match excel with negative and positive numbers

    Good day!
    Below is my data. I am trying to use index/match function to pick up both positive and negative numbers (0.096 & -0.65) from column C as my lookup value is 0. Then I need to pick up corresponding Column B values (5.5 & 6). So then I can interpolate. Index/match is picking up 0.096 from col C; but it is not picking up -0.65 from col C
    It is picking up 5.5 from column B for first value but it is not picking up 6. Below is the syntax I used, please help me in this regards

    =INDEX(C5:C15,MATCH(F5,C5:C15,-1)) this returns 0.096
    =INDEX(C6:C15,MATCH(F5,C6:C15,1)+1) #N/A
    =INDEX(B6:B15,MATCH(F5,C6:C15,-1)) 5.5
    =INDEX(B6:B15,MATCH(F5,C6:C15,1)+1) #N/A

    lookup value is 0

    B C
    2.5 93.77
    3 28.3
    3.5 10.83
    4 4.8
    4.5 2.25
    5 0.94
    5.5 0.096
    6 -0.65
    6.5 -1.25
    7 -2.63

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,922

    Re: index match excel with negative and positive numbers

    Assuming F5 contains the value 0 and C5:C15 is the full column of values under C:
    =INDEX(C5:C15,MATCH(F5,C5:C15,-1)) this returns 0.096
    0 is the lookup value in column C. -1 tells MATCH() that the values in column C are sorted in descending order, so it should find the value in column C that is 0 or just larger than 0 (0.096 in this case) and return the corresponding row number. INDEX() then returns the corresponding value from column C, which 0.096.
    =INDEX(C6:C15,MATCH(F5,C6:C15,1)+1) #N/A
    0 is the lookup value in column C. 1 tells MATCH() that the values in column C are sorted in ascending order (note that they are not). 0 is smaller than the first value in column C (93.77), so MATCH() returns N/A error. INDEX() simply propagates the error.
    =INDEX(B6:B15,MATCH(F5,C6:C15,-1)) 5.5
    0 is the lookup value. -1 tells MATCH() that the values are sorted in descending order, so MATCH() finds the value that is just larger than 0 (0.096) and returns the corresponding row number. INDEX() then returns the corresponding value from column B, which is 5.5.
    =INDEX(B6:B15,MATCH(F5,C6:C15,1)+1) #N/A
    0 is the lookup value. 1 tells MATCH() that the values are sorted in ascending order (they are not). 0 is smaller than the first value in the range, so MATCH() returns the N/A error. INDEX() then propagates the error.

    If I understand what you are trying to do, in the N/A cases, I think you want the "match type" argument to be -1 just like it is in the other cases. If I am misunderstanding what you want, perhaps the explanations above will help you understand what the INDEX(...MATCH()) combination is doing and can better formulate what you want to happen.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: index match excel with negative and positive numbers

    Assuming these values are in B6:C15 then:

    Please Login or Register  to view this content.
    Returns 5.564343 for me (although that assumes linear change)

    WBD
    Attached Files Attached Files
    Last edited by WideBoyDixon; 11-11-2021 at 01:46 PM.
    Office 365 on Windows 11, looking for rep!

  4. #4
    Registered User
    Join Date
    11-11-2021
    Location
    Durban
    MS-Off Ver
    2007
    Posts
    3

    Re: index match excel with negative and positive numbers

    Thank you for clarity of the syntax

  5. #5
    Registered User
    Join Date
    11-11-2021
    Location
    Durban
    MS-Off Ver
    2007
    Posts
    3

    Re: index match excel with negative and positive numbers

    Quote Originally Posted by WideBoyDixon View Post
    Assuming these values are in B6:C15 then:

    Please Login or Register  to view this content.
    Returns 5.564343 for me (although that assumes linear change)

    WBD
    Thank you. This works well. I am trying to understand first two codes.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,922

    Re: index match excel with negative and positive numbers

    I overlooked that this was, overall, an interpolation problem. Are you required to use Excel? Gnumeric has a built in INTERPOLATION() function that makes short, easy work of interpolation problems.

    For those who must use Excel, I like this approach to linear interpolation type problems: https://www.excelforum.com/excel-gen...ml#post4421017

  7. #7
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: index match excel with negative and positive numbers

    Quote Originally Posted by samiitr View Post
    Thank you. This works well. I am trying to understand first two codes.
    It's basically looking for the last row that has a value greater than zero. Using LOOKUP like this is pretty standard.

    WBD

+ 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. Combination of SUMPRODUCT and INDEX-MATCH, to sum all positive numbers.
    By PaolosKiE in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-25-2020, 02:04 AM
  2. [SOLVED] Index Match to pull negative and positive data
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-14-2019, 07:08 AM
  3. Turn positive numbers negative with Excel VBA
    By maxhecht2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-27-2017, 03:39 PM
  4. [SOLVED] Recognize and sum positive negative numbers from a string excel
    By Amolvijay in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-18-2014, 07:24 AM
  5. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM
  6. Replies: 3
    Last Post: 06-06-2009, 10:31 AM
  7. Replies: 4
    Last Post: 07-07-2006, 02:25 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