+ Reply to Thread
Results 1 to 16 of 16

A doosy- Complex logic for filtering - Can you figure it out?

  1. #1
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    A doosy- Complex logic for filtering - Can you figure it out?

    I have been trying to figure this out for days, but I just cannot get everything to work. I can get some scenarios to work, but not all at the same time. It is very bazaar and frustrating. Even ChatGPT can't get it right.

    Please download and look at the workbook in the attached zip file. It will make what is needed much easier to understand.

    Setup:
    • I have a worksheet called "Libraries" with a listing of sample libraries, with columns for (A)Vendor, (B)Library Name, (C)Library Subgroup, and (D)Patch Name.
    • I have a "Report" worksheet where I am doing filtering on the data in the Libraries sheet.
    • Ok, on the Report sheet I have 3 cells, C11 to E11 which are for inputting text to filter by. C11 filters over column Libraries!B, D11 over Libraries!C, and E11 over Libraries!D. The filter restricts the result listing more as more of cells C11 to E11 get text to filter on, as in the resulting list has to contain only records from Libraries that match all of the specified text as per the corresponding column. I hope that makes sense.
    • Also on the Report sheet is cell C13 which is for specifying filter text which should be a match if ANY of the 3 columns in Libraries contains the specified text.
    • Finally on the Results sheet is the cell (C17) containing the filter formula, which becomes the first row of a column of the resulting filtered list. There are other columns that are similar but for simplicity just focus on getting C17 to work putting correct results in that column. Also, ignore the other text cells on the Report sheet.

    This formula below (in cell C17) seems to work for every scenario of these inputs except when there is text only in C13, in which case it is like that text is ignored - I basically just get as the result the entire list as if no filter text has been specified.
    But if I change the '+' before the IF to a '*', then the lone text in cell C13 works, but other scenarios do not.

    The formula I have now:

    =IFERROR(
    FILTER(
    Libraries!B2:B500000,
    (
    ( ISNUMBER(SEARCH(LOWER(Report!C11), LOWER(Libraries!B2:B500000))) *
    ISNUMBER(SEARCH(LOWER(Report!D11), LOWER(Libraries!C2:C500000))) *
    ISNUMBER(SEARCH(LOWER(Report!E11), LOWER(Libraries!D2:D500000))) )
    +
    IF(Report!C13<>"",
    ( ISNUMBER(SEARCH(LOWER(Report!C13), LOWER(Libraries!B2:B500000))) +
    ISNUMBER(SEARCH(LOWER(Report!C13), LOWER(Libraries!C2:C500000))) +
    ISNUMBER(SEARCH(LOWER(Report!C13), LOWER(Libraries!D2:D500000))) ) )
    ) > 0

    ),
    ""
    )

    If you can solve it you will be forever known as a genius.
    PLEASE SOLVE IT!
    Thanks.
    Attached Files Attached Files
    Last edited by lahatte; 09-20-2023 at 12:38 AM. Reason: Post smaller file

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Ahich version of Excel are you using?
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Please add the blue part in the formula of B17 and it will work:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    I am using Office Excel 2016, but it might be good if it could work on some earlier versions, but that's not at all critical.

    EDIT: I am using Office Pro 2021.
    Last edited by lahatte; 09-19-2023 at 06:42 PM.

  5. #5
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Quote Originally Posted by HansDouwe View Post
    Please add the blue part in the formula of B17 and it will work:

    Please Login or Register  to view this content.
    Sorry, that doesn't work. Did you download the example workbook? Thanks.

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    I am using Office Excel 2016
    I don't think so you are using FILTER, but Excel 2016 does not have FILTER.
    You can check your version in Excel: Click on your account name (at the top) and then click Office user info. It should be 2019, 2021 or 365.

    Did you download the example workbook?
    But your file is too big and not very manageable. Please provide a sample sheet with a maximum of a few tens of rows, so that you can test it much more easily. I will return such a workbook with a working formula
    Last edited by HansDouwe; 09-19-2023 at 06:41 PM.

  7. #7
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Thanks for the tip on finding the version. I didn't know that was there.

    As for the workbook I attached, it's less than 3Mb, so I don't understand the problem with it. It's about as small and simple as I can get it.
    Last edited by AliGW; 09-20-2023 at 02:01 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    it's less than 3Mb
    3 Mb is not handy here.
    I have reduced your file size to approximately 120 KB. That is handy, and can be uploaded here without zipping.
    For some reason your file had a lot of empty rows that somehow took up a lot of space.

    Here is an uploaded file with the adjusted formula, which I think works well.
    If results are different than expected, I would like to hear about it.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Thanks for that.

    That seems to work for the various filters. However if no filters are specified the full list should be the result. This result is an empty list when there are no filters.

    For extra credit you can have a go at the "Exclude" text field in D13. The idea here is to exclude from the results list any records that have the specified text in any of the columns B, C, or D in the Libraries data.

    Thanks for your assistance!
    Last edited by AliGW; 09-20-2023 at 02:02 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.

  10. #10
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Which version of MS-Office are you using and please adjust this in your profile.

    Then we can take that into account.

    For extra credit ...
    I still have to receive the first credit .

  11. #11
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    I am in Office Pro 2021.

    As for the credit, well... the CONCAT is not doing the job because if you put text in two or more of C11 to E11 you get a string that isn't likely to exist in any of the fields. C11 pairs with Column B in Libraries, D with C, and E with D. Those keywords cannot be joined together for that part of the filtering.
    Last edited by AliGW; 09-20-2023 at 02:02 AM. Reason: Please do NOT quote unnecessarily! Use the QUICK REPLY button instead.

  12. #12
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Thanks for updating your profile.

    if no filters are specified the full list should be the result
    I have created a formula that returns the result of all the columns at once.
    To ensure that everything is returned in case no filter is used, I added the following: ( CONCAT(C11:E11,C13)="" ) * ( Libraries!A2:A22 <> "") +

    In addition, I have removed unnecessary parts for readability:
    - LOWER is not necessary, because SEARCH is not case sensitive
    - IFERROR is not needed, because FILTER has its own parameter in case nothing is found
    - IF .. > 0 is not necessary, because any result > 0 is returned.
    Please empty the whole table and try in B17:
    Please Login or Register  to view this content.
    the CONCAT is not doing the job because if you put text in two or more of C11 to E11 you get a string that isn't likely to exist in any of the fields
    Did you try it???
    The string C11:E11 is not compared to fields in your table. It only checks whether all three fields are empty or not.
    I have also tested with multiple fields filled in and that works well.
    If something doesn't work, please show it in an example.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Thanks very much, HansDouwe the Genius!

    That does now seem to be doing everything correctly. Much appreciated! I presume this will work in versions of Excel after 2016?

    Now do you want to try for the extra credit?
    Last edited by lahatte; 09-20-2023 at 01:53 AM.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    FILTER is available in Excel 2021 and Excel 365.

  15. #15
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,428

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    exclude from the results list any records that have the specified text in D13 in any of the columns B, C, or D in the Libraries data
    Please add the blue parts to the formula
    Please Login or Register  to view this content.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    10-19-2017
    Location
    Mississippi
    MS-Off Ver
    2021
    Posts
    19

    Re: A doosy- Complex logic for filtering - Can you figure it out?

    Quote Originally Posted by HansDouwe View Post
    Please add the blue parts to the formula
    Please Login or Register  to view this content.
    That seems to work perfectly.

    So, 2 questions:
    1. Do you think there is a way to make this operate faster?
    2. I wonder if you might know how this might be changed to work in some versions of Excel prior to 2021 and 365, if possible. It would be good if this was more portable to earlier versions. Maybe it would only work if coded in VBA. What do you think?

    Also, I intend to make this available to the composer community, and if I do, how would you like to be credited with your genius contributions?

    Thanks!
    Last edited by lahatte; 09-21-2023 at 12:12 AM.

+ 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. [SOLVED] Count smallest two against a figure in another column and use logic to get true or false
    By MD PERVEZ KHAN in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-20-2015, 06:54 AM
  2. [SOLVED] Filtering Logic - Consider Entire Dataset While Filtering
    By mikegs1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2014, 05:01 PM
  3. Complex If Logic (for me at least!)
    By cschmid1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-08-2012, 02:40 AM
  4. Complex IF AND Logic Help Needed!
    By FatsOnline in forum Excel General
    Replies: 6
    Last Post: 06-20-2012, 02:02 AM
  5. Match Help... A Doosy
    By chrisfreeman in forum Excel General
    Replies: 4
    Last Post: 03-23-2012, 02:25 PM
  6. [SOLVED] rather complex logic statement
    By [email protected] in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-31-2006, 03:40 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