+ Reply to Thread
Results 1 to 9 of 9

If array Formula (different True and False within a If function.

  1. #1
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    If array Formula (different True and False within a If function.

    Hello,

    I am trying to build a several Ifs within one array formula. Here is a simplified example to illustrate my problem:

    {=IF({"Item One";"Item Two";"Item Three"}="Item One",{1;2;3})}

    This works and Excel returns 1

    However if I change for "Item Two" I get a FALSE, I would like it to return 2!

    {=IF({"Item One";"Item Two";"Item Three"}="Item Two",{1;2;3})}

    Excel returns FALSE
    =FALSE

    If you know what I am doing wrong I would be very thankful for anyones feedback.
    Thanks for your time.
    -Phil

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

    Re: If array Formula (different True and False within a If function.

    Hi,

    Maybe just (array-entered):

    =MATCH(TRUE,{"Item One";"Item Two";"Item Three"}="Item Two")

    Or, non-array equivalent:

    =MATCH(TRUE,INDEX({"Item One";"Item Two";"Item Three"}="Item Two",,))

    Regards
    Click * below if this answer helped

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

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: If array Formula (different True and False within a If function.

    Hi,

    I suggest you upload your workbook which clearly shows examples of your input cells and the manually entered results you expect to see with a brief explanation as to how you calculate the result if it's not blindingly obvious from the example.

    It's not clear to me what you are attempting to do or why an array formula is necessary at all.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: If array Formula (different True and False within a If function.

    This formula

    =IF({"Item One";"Item Two";"Item Three"}="Item One",{1;2;3})

    returns an "array" of 3 values, i.e. {1;FALSE;FALSE}

    so you normally have to use that array in another function that can process arrays, or enter as an "array formula" in 3 cells to see all the results.

    If you enter in a single cell you normally just see the first value in the array, in this case 1...., so when you change the formula as you suggested the first value in the array is FALSE and you see that instead

    Can you explain what you want to do with that array....or is that the end result?

    If you want just 1 and 2 respectively then try using MATCH like this

    =MATCH("Item One",{"Item One";"Item Two";"Item Three"},0)

    ...or if the return number isn't always equal to the position

    =HLOOKUP("Item One",{"Item One","Item Two","Item Three";1,2,3},2,0)

    so you can change 1,2,3, as required
    Last edited by daddylonglegs; 11-14-2013 at 07:29 AM.
    Audere est facere

  5. #5
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: If array Formula (different True and False within a If function.

    Try:
    =LOOKUP("item1",({"item1","item2","item3"}),{1,2,3})
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  6. #6
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Smile Re: If array Formula (different True and False within a If function).

    Thank you so much for your suggestions!!! (very helpful)

    I tried to illustrate what I was trying to achieve in the attached Excel file.

    initally I was looking up items in a range using INDEX and MATCH formulas to return an integer corresponding to an item (e.g itemxxx = 1, ItemYYY = 2...)
    This Works, I then attempted to include the value in the range within a formula, therefore I used am IF array, but was unsuccesful.

    I hope the attached document makes it clearer.

    Thanks again for your help.
    - Phil
    Attached Files Attached Files

  7. #7
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: If array Formula (different True and False within a If function.

    For LOOKUP to work your item must be in ascending order:
    B27:
    =LOOKUP(A27,{"Item Five","Item Four","Item One","Item Three","Item Two"},{5,4,1,3,2})

  8. #8
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

    Re: If array Formula (different True and False within a If function.

    Thank you, I changed it in an ascending order and it worked. Thanks again!

  9. #9
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: If array Formula (different True and False within a If function.

    You are welcome.
    But still- hard coding is not the best approach.

    Please leave reputation points.

+ 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. [SOLVED] Return True/False by searching a value in an array of string
    By aiyathomas in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-30-2013, 12:35 PM
  2. [SOLVED] in this TRUE OR FALSE function, i want desired name instead of display true or false
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-15-2013, 06:44 PM
  3. Replies: 2
    Last Post: 08-02-2006, 06:10 PM
  4. IF function...>cell ref is a formula so True is retd when False sh
    By Alison in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-31-2006, 08:03 PM
  5. [SOLVED] Function to return True/False if all are validated as True by ISNU
    By Tetsuya Oguma in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-15-2006, 06:30 AM

Tags for this Thread

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