+ Reply to Thread
Results 1 to 6 of 6

Inconsistent SMALL Formula Results

  1. #1
    Registered User
    Join Date
    05-03-2022
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    21

    Inconsistent SMALL Formula Results

    Here is an image. The spreadsheet is attached.

    Imagexx.png

    Sample.xlsm

    References aside, the same formula appears in all rows in Year column 1. That formula correctly identifies that the year 2020 appears in the Weeks columns at left.

    A different formula appears in all rows in Year column 2. That formula correctly detects that the year 2021 does not appear in the Weeks columns in the first row. It also detects that 2021 does appear in the last three rows. But it fails to detect that the year 2021 appears in the Weeks columns in the second and third rows.

    The formula in the Year 2 column, unlike that in Year 1, uses the SMALL function. An example for Year 2, last row (i.e., cell G8):

    Please Login or Register  to view this content.
    Last edited by raywood1; 11-09-2022 at 05:08 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,852

    Re: Inconsistent SMALL Formula Results

    Try

    in G3

    =IFERROR(SMALL($A3:$D3,COUNTIF($A3:$D3,$F3)+1),"")
    Last edited by JohnTopley; 11-09-2022 at 06:31 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,850

    Re: Inconsistent SMALL Formula Results

    Just to be clear on the 'error', in an array such as 2020 2020 2021 2021, Excel sees 2020 as both the first and second smallest numbers, so 2021 would be the third smallest. That's what John's suggestion is overcoming here. So the formula is not actually inconsistent: it's doing exactly what it's being told to do.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    05-03-2022
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    21

    Re: Inconsistent SMALL Formula Results

    Thank you for that assist. I guess you're saying that, if I have 50 columns containing 2020 (which, in some cases, I do), the values returned by SMALL (k=1 to 50) will all be 2020.

    That seems to suggest, that if I were using something newer than Excel 2016, I would benefit from the UNIQUE function. I've looked for formulas or code providing a workaround, but what I've seen so far seems oriented toward producing vertical rather than horizontal lists, thus not filling Year columns to the right.

    My data includes more than two years in some cases, and the years are not necessarily contiguous. Example: one row might have a number of entries in each of 2003, 2020, and 2021. I think there are not more than five years in any single row. Not sure yet; I'll have to see what I get in the five Years columns (i.e., 1-5) that I have set up at present.

    To accommodate those additional columns, I tried modifying John's formula thus:

    =IF(MAX(Year columns to the left)=(John's formula), produce a blank, otherwise produce John's formula)

    But it seems John's formula is limited in any case to just one column (i.e., Year 2). Columns 3 through 5 are blank on all rows. I'm new to IFERROR and apparently don't quite understand it yet.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,852

    Re: Inconsistent SMALL Formula Results

    If you have a number of years ... in ascending order then try

    =IFERROR(SMALL($A3:$D3,COUNTIF($A3:$D3,"<=" & F3)+1),"")

    and drag across
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-03-2022
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    21

    Re: Inconsistent SMALL Formula Results

    Bingo! That works. I've prepended an IF statement to eliminate some odd duplication, like this:

    =IF(DTC4="","",IFERROR(SMALL($C4:$DSY4,COUNTIF($C4:$DSY4,"<="&DTC4)+1),""))

    and that seems to do it. Testing continues, but so far it looks great.

    Thank you again for your help. The larger project that this feeds into is still in progress, but in case anyone is interested, I've got an intermediate post that provides some context.

    Keep up the good work!

+ 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. Same formula generating inconsistent results
    By Ochimus in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-24-2021, 03:57 PM
  2. [SOLVED] Problem with a simple Index Match formula returning inconsistent results
    By SueBristow in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-20-2017, 06:44 AM
  3. [SOLVED] Index Small If Row Column formula not returning all results
    By EmmatheDancer in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-10-2015, 06:34 AM
  4. Inconsistent results for formula
    By Maxwel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-27-2014, 08:04 PM
  5. [SOLVED] ERROR!!! My formula gives inconsistent Results
    By rojashan in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-27-2014, 09:11 AM
  6. If/VLookup/Match Formula Results Inconsistent
    By hardpenguin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2010, 05:05 PM
  7. Formula producing inconsistent results
    By joseclar in forum Excel General
    Replies: 5
    Last Post: 05-20-2009, 01:41 PM

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