numbers function lookup

I am a newbie. I had been googling, reading for a few hours and can't seem to figure out what was wrong with my function. It's a simple lookup where I look up a value and it will return a sum of 2 values.

B2 = LOOKUP(A2,'Table 1-1'::A2:A5,'Table 1-1'::B2:B5+'Table 1-1'::C2:C5)

B3 =LOOKUP(A3,'Table 1-1'::A2:A5,'Table 1-1'::B2:B5+'Table 1-1'::C2:C5)

the only different is the reference but it keep giving me 'unknown value return error'

If I take out the addition to the result on B3, it will return the value 2.

If I change A3 to A2 on cell B3, it will return the value 5 just like cell B2. I am so frustrated. Can someone please tell me what's wrong?

Thank you


User uploaded file

MacBook Pro, iOS 10.3.1, null

Posted on Apr 20, 2017 9:17 PM

Reply
6 replies

Apr 21, 2017 5:41 AM in response to CKssS

Hi CK,


LOOKUP generally takes 3 arguments. Returning a second value from another column requires a new instance of the LOOKUP statement.


LOOKUP(search-for, search-where, result-values)


search-for, A2 the cell on 'this table' containing the value to search for.

search-where, Data::A the range of cells in which to search

result-values Data::B the range of cells from which to return the value in the same position as the value found


User uploaded file

The formula shown below the table is the one in the selected cell, B2 of the Result table.

The formula is filled down to cell B3.


Regards,

Barry

Apr 21, 2017 4:46 AM in response to CKssS

Hi CKssS,


Instead of LOOKUP, which as ancient function from the early days of spreadsheets that has been largely replaced by the more modern equivalents of VLOOKUP and INDEX MAX, you should find things easier if you reorganize your data in a "normalized" vertical format and use SUMIF or SUMIFS. This approach is particularly helpful if you will have values for more than two dates, as instead of chaining multiple functions to address an unwieldy number of columns, you simply add new rows to the data table and the formulas automatically adjust to include the new values.


User uploaded file


The formula in B2, copied down to B3.


=SUMIFS(Data::C,Data::A,$A2)


More on SUMIFS here.


SG

Apr 21, 2017 10:39 AM in response to CKssS

"What I get confused was why the equation worked in Cell B2 but not in Cell B3."


If the formula is identical to what's shown below your table (except for the A3 reference being to A2 in the first), I'm surprised that it does work in B2.


Revising my formula to match yours (but using the full column references rather than specifying the X2:X5 style ranges you've used), I expected a syntax error result, but got a 'LOOKUP can't find the value' error, which I found a bit confusing as well! Will probably take a further look at that is I have time this evening.


SGIII's comments regarding LOOKUP vs VLOOKUP or INDEX and MATCH are well taken. "More precise" in this context refers to the ability to specify 'exact' or 'close' matches to the search value.

LOOKUP always accepts a 'close' match if an 'exact' match isn't available.


In your case, provided any value entered into column A of the results table is an exact match for one of the values in column A of the data table, LOOKUP will do the job well. What it won't do is throw up an error flag if there's not an 'exact' match, but there is a 'close' match. In that case, LOOKUP (and VLOOKUP or MATCH, when not set to require an exact match) will take the 'close' match and return what could be a wrong value.


Regards,

Barry

Apr 21, 2017 12:27 PM in response to CKssS

Hi CKssS,


If you use LOOKUP (which generally is very rare these days; most people use the more precise VLOOKUP and INDEX MATCH) then you must chain two together as in Barry's example. I think your first one "worked" only by chance; it appears to be incorrect syntax.


As a newcomer to Numbers you can learn a lot by studying the templates at File > New in your menu. Also recommend having a look in the Help menu at Numbers Help and Formulas and Functions Help.


SG

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

numbers function lookup

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.