+ Reply to Thread
Results 1 to 28 of 28

Replacing Small Function with xSmall....

  1. #1
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs up Replacing Small Function with xSmall....

    Hi Folks,
    As usual .. I am back with some thing new on my side...

    This I get rid of cons of Small function... that we all fed up with..

    Actually the reason I made xSmall function is that.. Small function don't ignore zeros while calculating kth Small..
    So I think.. why not making its better alternative..

    have a visit.. at the link below... to explore more..
    http://excel-buzz.blogspot.in/2014/0...small-udf.html

    Code for xSmall is
    Please Login or Register  to view this content.
    If any of you thinks.. that there is a room for improvement.. or there is a better alternative..
    then Don't hesitate... have a comment..

    Regards,
    Vikas Gautam

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Thumbs up Re: Replacing Small Function with xSmall....

    oh I forgot to attach a sample workbook...

    but now I have...
    Attached Files Attached Files

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

    Re: Replacing Small Function with xSmall....

    Hi again,

    Of course we can do this with a simple extra clause using worksheet functions:

    =SMALL(A1:A10,k+COUNTIF(A1:A10,0))

    will return the kth smallest value from A1:A10 excluding zeroes.

    Regards
    Click * below if this answer helped

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

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Sorry Xor,
    you are correct at your place..
    but countif don't recognize arrays..

    so to counter this .. I have come with xSmall...

    Thanks for commenting..

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Quote Originally Posted by Vikas_Gautam View Post
    but countif don't recognize arrays..
    Sorry, Vikas. What do you mean by this?

    You mean arrays which are not an actual worksheet range reference, but e.g. the array produced by intermediate functions within a formula?

    Can you give an example?

    Regards

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    yeah... for example.. --(A1:A10=B1)
    produces an array... which gives Value Error when used in countifs..

    You can also see while entering Countif formula.... that it demands RangeCriteria not ValueCriteria..

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Sure, but you're not restricted to using COUNTIF in these constructions.

    Though I also don't think the example you've given is a very good one (the returns are either 0 or 1) since (array-entered):

    =SMALL(--(A1:A10=B1),k+COUNTIF(A1:A10,"<>"&B1))

    gives you the kth smallest value excluding the zeroes (which will in any case be a 1 in this example, assuming such a kth smallest non-zero value exists.)

    Basically, I think that there's just about always a way to achieve this extraction using additional function(s) within the formula.

    Regards
    Last edited by XOR LX; 08-12-2014 at 03:00 AM.

  8. #8
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Okay XOR Let it be..
    Give me a formula to result 1st non-zero small in the following Array...
    ={1;0;2;0;0;0;3;0;4;0}
    you formula..
    =Small({1;0;2;0;0;0;3;0;4;0},1 + Countif({1;0;2;0;0;0;3;0;4;0},0)) will not work here and will give Value Error..

    Sorry for anything..

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Actually, I very rarely use the COUNTIF approach myself. I was simply demonstrating one possibility. My own way, given such an array, is to use (array-entered):

    =SMALL(IFERROR(1/(1/({1;0;2;0;0;0;3;0;4;0})),""),k)

    Of course, this works when excluding zeroes, but not necessarily any other value.

    However, since excluding zeroes is quite a common requirement in Excel (I think that Microsoft should get round to developing an IFZERO() function simiiar to IFERROR()) then this approach is quite useful, not to mention nice and short!

    Regards

  10. #10
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    What a way.. out.. XOR..
    where you were hiding it. now..

    Thanks..
    I will work upon it. now..

    Thanks,
    XOR..

  11. #11
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    XOR....
    the formula you provided me has one inherent limitation..(Don't Mind)

    "I has to be entered as array formula.."

    If you can get rid of it..
    that would be wonderful....

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Not sure why that's such a "limitation", but if you insist you can add an INDEX:

    =SMALL(INDEX(IFERROR(1/(1/({1;0;2;0;0;0;3;0;4;0})),""),,),1)

    By the way, I should say I do often use this approach for excluding values other than zero as well, especially in cases where you have an extremely long clause in a formula which you would otherwise have to repeat, e.g. instead of:

    =MIN(IF([results of large formula]<>0,[results of large formula]))

    we can use:

    =MIN(IFERROR(1/(1/([results of large formula])),""))

    But we can also adapt it slightly to exclude values other than zero, e.g. to find the minimum excluding the value 2:

    =MIN(IFERROR(1/(1/([results of large formula]-2))+2,""))

    And even get a little more creative. e.g. to find the minimum excluding negative numbers:

    =MIN(IFERROR(SQRT([results of large formula])^2,""))

    (Providing rounding issues are not a factor.)

    Regards

  13. #13
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Sorry XOR..
    Please Login or Register  to view this content.
    will not perform has array..
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    will perform as array..

    In short.. Arrays don't perform in IFERROR() as array..

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Quote Originally Posted by Vikas_Gautam View Post
    Sorry XOR..

    Please Login or Register  to view this content.
    will not perform has array..

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    No it doesn't!! Show me a workbook or screenshot of Evaluate Formula which gives that!

    =SMALL(INDEX(IFERROR(1/(1/({1;0;2;0;0;0;3;0;4;0})),""),,),1)

    becomes:

    =SMALL(INDEX(IFERROR({1;#DIV/0!;2;#DIV/0!;#DIV/0!;#DIV/0!;3;#DIV/0!;4;#DIV/0!},""),,),1)

    which is:

    =SMALL(INDEX({1;"";2;"";"";"";3;"";4;""},,),1)

    which is:

    =SMALL({1;"";2;"";"";"";3;"";4;""},1)

    as required.

    No idea what you've been doing!

    Regards

  15. #15
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Hi XOR,
    Sorry for wrong conclusion..
    Actually I tried Index ... But that was in a hasty way...

    You are correct..
    Absolutely correct..

    But if you can fit your concept in my second formula ..
    I will be obilged..

    See the attached file...


    Vikas Gautam
    Attached Files Attached Files

  16. #16
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    I have tried this.. But its not working...

    =INDEX(C1:C14,SMALL(INDEX(IFERROR(1/(1/(INDEX(COUNTIFS(F1,A1:A14,F2,B1:B14)*ROW(B1:B14),,))),""),0),F3))

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    Not sure I understand. What's wrong with the current solutions you have? Look perfectly fine to me.

    Are you sure you're not just trying to avoid array formulas for the sake of it?

    This reminds me of the ridiculous situation I was in about a year ago (and which I told you about) when I was adding several extra INDEX functions in an attempt to avoid array-entry...

    Regards

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

    Re: Replacing Small Function with xSmall....

    If you absolutely insist:

    =INDEX(C1:C14,SMALL(INDEX(IFERROR(N(INDEX(1/(1/(COUNTIFS(F1,A1:A14,F2,B1:B14)*ROW(B1:B14))),,)),""),,),F3))

    though the triple coercion required from the three extra function calls (two INDEX plus one N), not to mention the IFERROR, frankly makes this a slightly ridiculous solution.

    You see what I mean when I talk about "avoiding" array formulas now?

    Regards
    Last edited by XOR LX; 08-12-2014 at 11:17 AM.

  19. #19
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Absolutely XOR..
    That is why I made a Function.. xSmall.. to avoid the complexity involved in Non-array Construction....

    Thanks.. again..

    Vikas Gautam

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

    Re: Replacing Small Function with xSmall....

    But there's nothing wrong with array formulas!!

    Regards

  21. #21
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Replacing Small Function with xSmall....

    Quote Originally Posted by XOR LX View Post
    But there's nothing wrong with array formulas!!
    +1

    It's painful to see the extent to which some folks go to avoid array formulas!

    Not having array formulas available is like a carpenter showing up on the job without a hammer.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  22. #22
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Yeah.. XOR..
    There is nothing wrong with array formulas..
    But for a layman .. I suppose its more easier to use functions like xSmall ...

    Array functions are for people like us..
    we will definitely use it.. because of its beautiful construction...

    Apart from it..
    I actually expected from you people to improve the code..

    Vikas Gautam

  23. #23
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Replacing Small Function with xSmall....

    @Vikas,

    Have to disagree with you, I would think it is much easier for a layman to use array formulas than UDF's! It is at least more trace-able for people to look at. They can use the formula auditing tool to see what it is happening, they can see the formula and what it is. With UDF's the "layman" would, if they could find where the calculation being done, find it difficult to follow what is happening, when it is written in VBA code and they would find it difficult to debug.

  24. #24
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Yeah.. Ragulduy..
    its your point of view...

    According to me a layman is a person who don't want to know what is happening behind the screen..
    if he just want to calculate nth non-zero small value.. he will put in a formula and enjoy the result..
    No room for debugging..

    Yeah I agree with the point that there is FORMULA AUDITING available..
    but that is useful after a layman put the array formula.. (which he can't as he do not know ... how to approach...)

    Pls Don't mind my words.. I am just explaining you mine point of view..

    otherwise the approach given by XOR is fantastic.. (as I don't know it before..)

    Regards
    Vikas Gautam

  25. #25
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Replacing Small Function with xSmall....

    What I meant by debugging, is if the person has a calculation spreading various cells with different formulas. With a VBA/UDF solution it is near-impossible for a person without specialised knowledge to follow the calculation and see what is happening, to find the error.

    Whilst you are correct that the formula auditing is only useful after the array formula has been entered, you could use the same logic for a UDF, it is only useful (for the person to put in a formula and enjoy the result) once it has been entered into the vba editor (which the person can't do as they don't know how!).

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

    Re: Replacing Small Function with xSmall....

    Quote Originally Posted by Vikas_Gautam View Post
    if he just want to calculate nth non-zero small value.. he will put in a formula and enjoy the result..
    Quote Originally Posted by ragulduy View Post
    Whilst you are correct that the formula auditing is only useful after the array formula has been entered, you could use the same logic for a UDF, it is only useful (for the person to put in a formula and enjoy the result) once it has been entered into the vba editor (which the person can't do as they don't know how!).
    Agreed with ragulduy. The whole premise on which this idea is based seems to boil down to the idea that using a UDF is far simpler for an average Excel user than is committing an array formula.

    Since I started using a clear, descriptive footer in my posts pointing out how array formulas should be entered (as do the majority of other long-term contributors), I've barely had a single person come back to me complaining that they couldn't get it to work.

    The facts are:

    1) Array formulas are not difficult to enter with a bit of guidance

    2) UDFs are no more self-evidently simple than array formulas

    3) Use of array formulas should not in any way be avoided/discouraged

    Array formulas are something that we should actively promote in our posts, not seek for ways to circumvent their use. They are a fascinating and necessary part of this wonderful tool we call Excel, and we, as regular forum members, should do what we can so that more people may first understand, explore and then enjoy this feature.

    Regards
    Last edited by XOR LX; 08-13-2014 at 06:01 AM.

  27. #27
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    I think our debate.. is getting changed in to a friendly fight now...
    I think I should accept the thought, in front of you people, which I had agreed ...

    Long live arrays.. Long live UDFs..

    Vikas Gautam

  28. #28
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Replacing Small Function with xSmall....

    Now lets move our steerings to my next post ...
    which I have made Array friendly and UDF friendly as well...

    I think you both will like the concept in the link below..
    http://www.excelforum.com/tips-and-t...-countifs.html

    Please Don't hesitate and have your comments posted..

    Vikas Gautam

+ 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. Replacing cell numbers with text, small problem...
    By RASelkirk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-29-2011, 05:53 PM
  2. Use SMALL function
    By excelhelp456 in forum Excel General
    Replies: 4
    Last Post: 06-23-2009, 02:43 PM
  3. SMALL function
    By BusDriver2 in forum Excel General
    Replies: 6
    Last Post: 04-26-2009, 09:43 AM
  4. small function
    By navigator25 in forum Excel General
    Replies: 2
    Last Post: 10-24-2008, 12:24 AM
  5. Small Function
    By windme in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-13-2008, 03:13 PM

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