• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

CHOOSE Function

ananthram

New Member
Hi All excel Ninjas,


can anyone please tell me why is index_number should be {2,1} and why is it needed, how can i write formula using this? and if i give one number like {1} why it doesn't work?


Syntax :
Code:
CHOOSE(index_num, value1, [value2], ...)


My Formula : CHOOSE({2,1},$B$2:$B$10,$D$2:$D$10)
 
oh actually i also dont know why is that here. But i dont know what other type of parenthesis supports for this formula... can u please suggest me or explain y is that
Code:
index_num
needed
 
Anathram


Can you share the file or part of the file where your using it?

Is it part of a larger formula ?
 
Hi Ananthram


Syntax : CHOOSE(index_num, value1, [value2], ...)


For example: In A1 a number 1 to 7 (index_num), Value1= "Mon",Value2 ="Tue" etc to Value7 ="Sun".


Have a look here for more detail on the CHOOSE function.

http://office.microsoft.com/en-gb/excel-help/choose-function-HP010069830.aspx
 
Ananthram


CHOOSE syntax:

=CHOOSE(index_num, value1, value2, value3…..up to 254 values)

With an example:

=CHOOSE(3,“ Blue”,”Green”,“Orange”)

Translated the formula reads:

=CHOOSE(value number 3 where, value 1 = Blue, value 2 = Green, value 3 = Orange)

The result is Orange
 
@hui


Code:
=VLOOKUP(LARGE($D$1:$D$20,3),CHOOSE({2,1},$B$1:$B$20,$D$1:$D$20),2,0)


this is the actual formula...


but i still not getting why is it used... :(
 
Hi Ananthram ,


This construct is used to form a single multiple column and multiple row range out of non-contiguous ranges.


For example , if you want to do a matrix multiplication of say a 4 x 2 matrix , by another 2 x 4 matrix , where say the first matrix has non-contiguous ranges ; you can use this construct to form the matrix.


Let us say you have three ranges : G3:G6 , I3:I6 and K3:N4.


The following formula , entered over a 4 x 4 range , and entered as an array formula will do the matrix multiplication.


=MMULT((CHOOSE({1,2},G3:G6,I3:I6)),K3:N4)


In the example you have given , the first parameter of the VLOOKUP function is a single value , returned by the LARGE( ... ) function. The second parameter of the VLOOKUP function is supposed to be a range ; since you have two non-contiguous ranges , the CHOOSE( ... ) function combines them both into one range having two columns and 20 rows.


What you are doing with the LARGE function is retrieving the third highest value in the range D1:D20 ; since you wish to retrieve the corresponding value in the column B , which is to the left of column D , you do a VLOOKUP of the value in column D and then use 2 in the third parameter to retrieve the corresponding value from the second column of the range , which because you have used CHOOSE({2,1},....) is column B.


The composite range is formed by taking D1 , then B1 , then D2 , then B2 and so on :


{D1,B1;D2,B2;D3,B3;....;D19,B19;D20,B20}


Narayan


P.S. I realized that your question of why {1} does not work was not addressed ; so here goes.


When you use {1} , what you are doing is create an array of values from the range mentioned first , which in your case is D1:D20 ; so when you use 2 as the third parameter , then there is no second column to fetch a value from ; you should get a #REF! error.
 
Hi Ananthram,


As you already guided by "Great Formula Evaluator", So its a waste of time.. if you look at below post..


just kidding.. check the below link for detail..

http://chandoo.org/wp/2012/09/06/formula-forensics-no-028/


Regards,

Deb
 
Back
Top