+ Reply to Thread
Results 1 to 29 of 29

When would someone use the Choose function?

  1. #1
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    When would someone use the Choose function?

    Hi, I've just stumbled upon the Choose function for the first time. I understand the concept but I can't see a practical use for it. Take the following

    =Choose(3,"Sunday","Monday","Tuesday") Returns "Tuesday"

    I cant see the benefit of it. Would someone be able to post a scenario when it would be useful please?

    Thanks
    John

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: When would someone use the Choose function?

    People frequently write scenarios in which the formula needed is completely (or at least notably) different based on some prior calculation. One awesome benefit of the CHOOSE function is to allow you to activate one formula in a series of possible formulas without nesting IF inside IF inside IF ad nauseum.

    =CHOOSE(B3, Formula1, Formula2, Formula3, Formula4)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: When would someone use the Choose function?

    CHOOSE(K25,SUM(C20:N20),AVERAGE(C20:N20),MAX(C20:N20),MIN(C20:N20)) in K25 i have a dropdown going from 1-4. Choose on it's own you'd probably not use, but in this situation im able to select from 1 to four and have whatever functions result displayed. So if i want to sum my range, i choose 1 average choose 2. You can use it this way to choose a function like i've done, but it can also be used in conjunction with Vlookup for instance if you want to choose different tables from which to get your result.
    Windows 7 using Office 2007 & 2010

    Remember your [ code ] [ /code ] tags, makes reading soooo much easier

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: When would someone use the Choose function?

    I love the "ad nauseum" bit !

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

    Re: When would someone use the Choose function?

    This formula returns the next working day after TODAY() (assuming working days are Monday to Friday)

    =CHOOSE(WEEKDAY(TODAY()),1,1,1,1,1,3,2)+TODAY()
    Audere est facere

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: When would someone use the Choose function?

    You can avoid errors (like Donkeyote does) link in this example:


    the use of CHOOSE allows you to build an array of 2 values against which you can search according to the criteria value (in our case Z repeated 255 times)

    =LOOKUP(REPT("Z",255),CHOOSE({1,2},"",formula result))

    The first value in the 2 value array is always a Null (text), the second is the variant output of the formula (may be anything - text or error).
    One of the advantages of LOOKUP is that it will ignore values in the array that do not match the type of the criteria, this includes errors...
    By using a BIGTEXT type criteria value the LOOKUP will return the last text string it finds in the 2 value array, ie:

    =LOOKUP(REPT("Z",255),CHOOSE({1,2},"","Apple"))

    will return Apple

    =LOOKUP(REPT("Z",255),CHOOSE({1,2},"",NA())

    will return Null as #N/A is ignored given it is not text like the criteria.

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

    Re: When would someone use the Choose function?

    in an excel work book is where i'd use it oh sorry it's asked when not where.
    mostly tuesdays and sometimes on a friday.
    Last edited by martindwilson; 11-15-2010 at 11:17 AM.
    "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

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

    Re: When would someone use the Choose function?

    ....or create a single array out of two discontiguous ranges.....

    =CHOOSE({1,2},D2:D1000,A2:A1000)

  9. #9
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: When would someone use the Choose function?

    @martindwilson: LOL

    @johncassell:

    Or this mine solution for (I think) some score output for clubs (1, X or 2)

    http://www.excelforum.com/excel-gene...f-formula.html

    Needing to create an IF formula which would give the following as the outcome.

    e.g. IF c2>E2 the outcome would be given as 1, if C2<E2 then the outcome would be given as 2 and if C2=E2 then the outcome would be given as X.

    Any help appreciated.


    =CHOOSE(SIGN(A1-B1)+2, 2, "x", 1)

  10. #10
    Forum Contributor
    Join Date
    07-07-2005
    Location
    England
    MS-Off Ver
    Office 2019 Enterprise
    Posts
    462

    Re: When would someone use the Choose function?

    Thanks, I think I see now. So its maybe more a tool for people who don't really know formulas. We can provide them a list of numbers to select from instead of them having to enter a new formula.

    Cheers, really helpful
    John

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: When would someone use the Choose function?

    Quote Originally Posted by daddylonglegs View Post
    ....or create a single array out of two discontiguous ranges.....

    =CHOOSE({1,2},D2:D1000,A2:A1000)
    Daddy, can you elaborate on that, please?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  12. #12
    Valued Forum Contributor scottylad2's Avatar
    Join Date
    09-03-2010
    Location
    edinburgh
    MS-Off Ver
    Office 2007 Prof & Office 2010 Student Edition
    Posts
    629

    Re: When would someone use the Choose function?

    Quote Originally Posted by johncassell View Post
    Thanks, I think I see now. So its maybe more a tool for people who don't really know formulas. We can provide them a list of numbers to select from instead of them having to enter a new formula.

    Cheers, really helpful
    John
    on the contrary, it's used by those that maybe want more than 1 formula when doing stuff like stats for instance. you can check things like the mode and average without having to do entirely different formulas. Or like i said, you may want to do a vlookup and depending what you lookup might have a bearing on what table you choose an answer from. Type a search in youtube, there's some excelent examples on there

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

    Re: When would someone use the Choose function?

    Quote Originally Posted by NBVC View Post
    Daddy, can you elaborate on that, please?
    Here's a fairly trivial example. How to do a "Left lookup" using VLOOKUP rather than INDEX/MATCH...

    Lookup "x" in D2:D10 and return the corresponding value from A2:A10

    =VLOOKUP("x",CHOOSE({1,2},D2:D10,A2:A10),2,0)

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: When would someone use the Choose function?

    Okay, see what you meant... thanks.

    I assumed you meant as you wrote it: =CHOOSE({1,2},D2:D1000,A2:A1000) with the = in front (stand alone function).. so wasn't getting it...

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

    Re: When would someone use the Choose function?

    Quote Originally Posted by daddylonglegs View Post
    Here's a fairly trivial example. How to do a "Left lookup" using VLOOKUP rather than INDEX/MATCH...

    Lookup "x" in D2:D10 and return the corresponding value from A2:A10

    =VLOOKUP("x",CHOOSE({1,2},D2:D10,A2:A10),2,0)
    not seen that approach before ....

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: When would someone use the Choose function?

    Quote Originally Posted by DonkeyOte View Post
    not seen that approach before ....
    Yes, so many ways to skin that poor cat, aren't there?

  17. #17
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: When would someone use the Choose function?

    Quote Originally Posted by daddylonglegs View Post
    Here's a fairly trivial example. How to do a "Left lookup" using VLOOKUP rather than INDEX/MATCH...

    Lookup "x" in D2:D10 and return the corresponding value from A2:A10

    =VLOOKUP("x",CHOOSE({1,2},D2:D10,A2:A10),2,0)
    Wowsers! I love a great new construct. A fairly simple workaround to trick a VLOOKUP() into returning values from the left, that is pretty awesome.

  18. #18
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: When would someone use the Choose function?

    Can't get ddll's solution to work. get an N/A answer although x exists in D col

  19. #19
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: When would someone use the Choose function?

    works for me...
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: When would someone use the Choose function?

    How does choose treat the backslash?

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

    Re: When would someone use the Choose function?

    Is it a regional settings issue? If you have Dutch (Belgian) settings then I think the formula would be like this

    =VLOOKUP(E1; CHOOSE({1\2}; $C$1:$C$7; $A$1:$A$7); 2; 0)

  22. #22
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: When would someone use the Choose function?

    Thx ddll that is what JB used. But I don't understand how it works and in particular the part between brackets

  23. #23
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: When would someone use the Choose function?

    CHOOSE() normally expects a single answer in the first parameter. From that number the "option" further in the parameters is "opted for".

    This construct uses an array in the first parameter which basically says, "choose 1 and 2".

    Since "1" refers to a range of cells in column C, it is "grabbed" first, then the "2" refers to a range of cells in column A, so it is grabbed next.

    Then the magic, the two arrays are "mixed" creating an on-the-fly array of paired values. C1 pairs with A1, C2 pairs with A2, etc.

    Now that the paired arrays are created, the VLOOKUP finds the E1 value in the first range, then returns the matching value from the found pair.

    It's pretty cool to watch if you click on the cell and use the Formula Auditing tool on it to watch it unfold one calc at a time.

  24. #24
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: When would someone use the Choose function?

    Thx for the help JB. The use of the backslash in my regional settings was what bothered me most. Anyway, it's an inventive solution, I must say.

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

    Re: When would someone use the Choose function?

    The backslash is the inline column separator for your locale - you are building a vector/matrix 1 to n columns wide where 1 to n is determined by the CHOOSE inline array (height being determined by the ranges passed).

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

    Re: When would someone use the Choose function?

    i like that, works just as well with choose{1,2,3} any one tried up to 29?

  27. #27
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: When would someone use the Choose function?

    Thanks Gurus thats a very good read..
    Never knew that one could tame the most popular VLOOKUP to give the value from the WRONG side..

    Quote Originally Posted by JBeaucaire View Post

    CHOOSE() normally expects a single answer in the first parameter. From that number the "option" further in the parameters is "opted for".

    This construct uses an array in the first parameter which basically says, "choose 1 and 2".

    Since "1" refers to a range of cells in column C, it is "grabbed" first, then the "2" refers to a range of cells in column A, so it is grabbed next.

    Then the magic, the two arrays are "mixed" creating an on-the-fly array of paired values. C1 pairs with A1, C2 pairs with A2, etc.

    Now that the paired arrays are created, the VLOOKUP finds the E1 value in the first range, then returns the matching value from the found pair.

    It's pretty cool to watch if you click on the cell and use the Formula Auditing tool on it to watch it unfold one calc at a time.
    That's so important to know..

    Warm Regards
    e4excel

  28. #28
    Registered User
    Join Date
    10-03-2010
    Location
    Brussels, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: When would someone use the Choose function?

    ******* Where would someone NOT use the Choose function? ***********
    I was out curiosity looking on the web at the use of Choose function I never used before.

    I was 'fascinated' by daddylonglegs' with the '=CHOOSE({1,2},D2:D1000,A2:A1000) + CTL + SHIFT + Enter approach.

    So I tried it and played with it with success. Impressive. However, I could get the same results with a combination of vlookup & index function, in a limited test example. I still have to ingest where one is more appropriate / wider than the other.

    But I tried Choose to solve a more mundane problem, trying to create dynamic data validation for a column in long worksheet, where a value in column n+1 depended on values in column n on same row, which led me to the following.

    I just tried the following formula with Choose, where each of the 1 + 6 ranges to test correspond to names created referring to arrays of constant values in the workbook.

    Here is the data validation formula for the list to pick the right range:

    '=choose(MATCH(RC[-1],t_RS_NFR_Sub_Area_1,0),"",t_RS_Control_and_Processing_Risk,t_RS_Information_Technology_Risk,t_RS_Compliance_Risk,t_RS_Fraud_Risk,t_RS_BCP_Risk,t_RS_Employment_Practice_Risk)

    Now, interestingly, after typing this data validation as an input for the list in data validation, it worked perfectly ... for that cell. If I copied it one by one, it worked also, perfectly.

    But when asking to extend this data validation to all other cells with same data validation rule (ticking the box below the data validation window), it does it (it copies it fine in each cell of the column). However, when testing its effectiveness, it seems that Excel does not internally re-evaluate dynamically the content: it applies the same range to all rows the column, defeating the purpose.

    So I went back to an old trick of replacing the data validation formula with '=indirect(RC[66]) where in column +66 (in this spreadsheet), I store in a work column the name of the relevant range depending of the value in column -1.

    When I copy the 'indirect(RC[66]) function as data validation rule for all cells(rows) in the column, Excel re-evaluates this validation rule at each row (contrarily to the previous solution with choose, more elegant if it had worked). Both the formula was effective AND its copy to all cells with same data validation provided an effective solution.

    I use RC instead of A1 referencing just to make it clearer for this example.

    So, unless mistaken, this "inability to extend AND to use effectively Choose in this instance" seems an internal deep buried limitation of Excel 2010 when dealing with the data validation facility.

    So johncassell raised an interesting question considering above responses. Also to get some support to his challenging comment (cf. "its may be more a tool for people who don't really know formulas") !, he may also be right at least in this limited situation. Thanks to all.

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

    Re: When would someone use the Choose function?

    @acontrario

    Welcome to the forum. Is there a question here? Or are you simply posting some interesting findings of yours?

    In any case, it's a little difficult to follow your train of thought without an actual workbook example.

    Regards
    Click * below if this answer helped

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

+ 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