+ Reply to Thread
Results 1 to 26 of 26

Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

  1. #1
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    I have two formulae, both gleaned at different times from the helpful crowd here. What I am trying to do is get the alphabetised result that the first (array) formula offers, but adapted to work on filtered data like the second (non-array) formula that I am currently using.

    Formula 1 (in D936):

    =IFERROR(INDEX(SEF_Data_2018[TchGrp],MATCH(,COUNTIF(SEF_Data_2018[TchGrp],"<"&SEF_Data_2018[TchGrp])+9^9*(SEF_Data_2018[TchGrp]="")-SUM(COUNTIF(SEF_Data_2018[TchGrp],D$935:D935)),)),"")

    Formula 2 (in C936):

    =IFERROR(INDEX(SEF_Data_2018[TchGrp],MATCH(1,INDEX(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[School ID])-3,))*(0=COUNTIF($C$935:C935,SEF_Data_2018[TchGrp])),),)),"")

    The second formula will produce an alphabetical list if the data is sorted on the teaching group (TchGrp) column, but the data will not always be sorted that way, nor can it always be.

    What I would like is a list of unique values that are visible in the table when the list is filtered that will always present itself alphabetically. Teaching group codes are always text (essentially a mixture of numbers and text).

    I have attached a sample file - you'll need to scroll down to row 935 to see the formulae. The slicer is top right. I would like a formula, not VBA, PQ or advanced filters in this case.

    Thank you to anyone who can see how to combine the functionality of the two formulae I have already!
    Attached Files Attached Files
    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.

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    =COUNTIF($C$936:$C$947,"<"&C936)+COUNTIF($C$936:$C936,C936)
    and
    =INDEX($C$936:$C$947,MATCH(J936,$G$936:$G$947,))
    Attached Files Attached Files
    Last edited by tim201110; 06-09-2018 at 07:45 AM.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    I think you might struggle to do it all in one formula, Ali.

    Using a helper (if permissible), try this method

    In E4, filled down.

    =IF(SUBTOTAL(3,[@TchGrp]),COUNTIF([TchGrp],">="&[@TchGrp]))

    Array formula in C936, filled down as needed.

    =IF(ROWS(C$936:C936)>SUM(--(FREQUENCY(SEF_Data_2018[Column1],SEF_Data_2018[Column1])>0)),"",INDEX(SEF_Data_2018[TchGrp],MATCH(LARGE(SEF_Data_2018[Column1],SUM(COUNTIFS(SEF_Data_2018[TchGrp],C$935:C935))+1),SEF_Data_2018[Column1],0)))

    I'm not giving up on a helper free formula just yet, but I have a feeling that if it is possible, it could be extremely inefficient

  4. #4
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Whilst a helper column is not out of the question, the perfectionist (aka OCD) in me would love to find a one-formula solution, so if anyone has any advance on what is here, I'd love to know.

    In the meantime, thank you both very much for your help - I'll try them out and get back to you.

  5. #5
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Thanks again. For now, I've gone with Jason's solution, which requires just one helper column as opposed to Tim's, that needs two. As the data are not extensive, using an array formula is not a problem - thre will only ever be a maximum of 1000 rows.

    I'll mark this as solved, but will be very interested if anyone can do this in one hit!

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Cracked it with a single (array) formula, a very long single formula

    =IF(ROWS(C$936:C936)>SUM(--(FREQUENCY(IF(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[TchGrp])-3,0)),COUNTIF(SEF_Data_2018[TchGrp],">="&SEF_Data_2018[TchGrp])),
    IF(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[TchGrp])-3,0)),COUNTIF(SEF_Data_2018[TchGrp],">="&SEF_Data_2018[TchGrp])))>0)),"",INDEX(SEF_Data_2018[TchGrp],MATCH(LARGE(IF(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[TchGrp])-3,0)),COUNTIF(SEF_Data_2018[TchGrp],">="&SEF_Data_2018[TchGrp])),SUM(COUNTIFS(SEF_Data_2018[TchGrp],C$935:C935))+1),IF(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[TchGrp])-3,0)),COUNTIF(SEF_Data_2018[TchGrp],">="&SEF_Data_2018[TchGrp])),0)))

    I did try to shorten it by defining part of it in a named range, but that appeared to calculate slower. (still array confirmed).

    =IF(ROWS(C$936:C936)>SUM(--(FREQUENCY(test,test)>0)),"",INDEX(SEF_Data_2018[TchGrp],MATCH(LARGE(test,SUM(COUNTIFS(SEF_Data_2018[TchGrp],C$935:C935))+1),test,0)))

    where test refers to a named range defined with the formula

    =IF(SUBTOTAL(3,OFFSET(SEF_Data_2018[[#Headers],[TchGrp]],ROW(SEF_Data_2018[TchGrp])-3,0)),COUNTIF(SEF_Data_2018[TchGrp],">="&SEF_Data_2018[TchGrp]))

  7. #7
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Thanks, Jason! So, which of the three should I use? I’m away from the computer now for a bit, it will try it out later. Well done!

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Which method you use is a matter of suitability and your personal preference, Ali.

    Personally, I would use the first method with the helper column, it doesn't calculate instantly, but is only around a 1 second processing time, where as the single formula methods are taking much longer.

    Also, the helper column method doesn't use any volatile functions in the formula (or at least none that I recognise as volatile, not sure about subtotal).

    With the test sheet cleaned up to compare a little more accurately, the single formula method takes around 8 seconds to calculate, the shorter formula with the named range functioning as a hidden helper takes around 5 seconds. (not sure why that method was taking longer first time).

  9. #9
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Sorry, I meant the three formulae offered in your last post. However, I have re-read it now and get it! I'll try it out in a while - thanks.

  10. #10
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Jason - do you have a copy of my test file with the last version (the one with the named range) working, please? If so, can you attach it here? I can't get it working in my real workbook, and can't see why. I'm getting a #VALUE error on the FREQUENCY(test,test)>0 section of the formula.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Attached as requested, Ali.

    Are there any significant differences between the test and real files?

    I didn't test with blank rows, so possibly that could make a difference with blank = 0 causing mismatch errors.
    Attached Files Attached Files

  12. #12
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Thanks, Jason - I'll take a look now. No, there are no blank rows - I would have mentioned that at the start if it were a possibility.

  13. #13
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    It must be the way I set up the named range. I've obviously done it wrong, because I don't have {...} in the value field! I'm going to need a reminder how to do it properly - sorry!

  14. #14
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Fixed it - working now.

  15. #15
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Glad you got it working, Ali, is the formula returning the expected results?

  16. #16
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    I spoke too soon, I'm afraid - please try filtering to En on the slicer. Are you able to explain the #NUM error that produces? It returns four of the group names in alphabetical order, but misses two out.

  17. #17
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Bear with me, Ali, I'm looking at the incorrect results (3 missing, not 2 ), could take me a while to find the root of the problem though.

  18. #18
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    That's very kind of you - thanks! No desperate rush, but I'll be delighted if you can fix it. Yes, three missing (I'd forgotten we have 7 instead of 6 this year).

  19. #19
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Looks like it's back to the drawing board

    Same problem occurs if you filter on EnL, it's happening because the 2 subjects are classified under the same teaching group, which is giving false counts to the latter part of the formula.

    All 3 versions of the formula suffer the same fate. I have a fix in mind, just need to fit it to the formula.

  20. #20
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    OK, I understand. Sorry - I probably should have flagged that at the start. Thanks for the help - and as I said, no big rush.

  21. #21
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    I don't think that it is going to work with a single formula this time, best I can manage is with 2 helper columns.
    Attached Files Attached Files

  22. #22
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Thanks - I’ll have a look over coffee tomorrow morning.

  23. #23
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Quote Originally Posted by tim201110 View Post
    =COUNTIF($C$936:$C$947,"<"&C936)+COUNTIF($C$936:$C936,C936)
    and
    =INDEX($C$936:$C$947,MATCH(J936,$G$936:$G$947,))
    Tim - I revisited your solution, and discovered that it does not work unless the TchGrp column is sorted alphabetically, which sort of defeats the object if you read my OP again, but thanks for your attempt.

  24. #24
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Jason - thank you again. I have this working nicely in both of my real data files. Thank you both again for your help, especially Jason for sticking with it.

  25. #25
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    3 attempts
    it works
    Attached Files Attached Files

  26. #26
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,377

    Re: Adapt Fornula to Extract Unique List from Filtered Data Alphabetically

    Tim - which bit of this are you saying works?

    Excel 2016 (Windows) 32 bit
    D
    E
    F
    G
    H
    I
    935
    helper
    sorted with formula
    936
    10EngAu
    10AAr1
    6
    937
    10EngOr
    10AAr2
    11
    938
    10EngBr
    10AAr3
    7
    939
    10EngDi
    10AAr4
    8
    940
    10EngDu
    10ABS
    9
    941
    10EngSh
    10AFr
    12
    10EngAu
    942
    10EngEl
    10AGe
    10
    10EngBr
    943
    10AHi
    1
    10EngDi
    944
    10AMS
    2
    10EngDu
    945
    10AMu
    3
    10EngEl
    946
    10ASp
    4
    10EngOr
    947
    10BBS
    5
    10EngSh
    Sheet: 1

+ 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. Drop down dependent on previous filtered list - NOT SORTED ALPHABETICALLY
    By K Cooper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2018, 06:38 PM
  2. [SOLVED] how to extract unique list of names in filtered data
    By XLalbania in forum Excel General
    Replies: 15
    Last Post: 12-18-2016, 09:30 AM
  3. [SOLVED] Formula to get unique and alphabetically sorted list after matching a criteria
    By Saranya A in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-20-2016, 06:50 AM
  4. Extract unique text values from a filtered list
    By ljerromes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-23-2015, 07:51 PM
  5. [SOLVED] Dynamic Formula for Getting Unique Items from a list and sort them alphabetically
    By tuckertheguy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-18-2015, 03:57 AM
  6. [SOLVED] Formula to extract unique values from two excel tabs and sort alphabetically
    By rshukla in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2013, 01:48 PM
  7. [SOLVED] Unique distinct alphabetically sorted list
    By atlant15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:03 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