+ Reply to Thread
Results 1 to 11 of 11

SortBy & Filter Formula Trouble

  1. #1
    Registered User
    Join Date
    04-21-2022
    Location
    Houston, Texas
    MS-Off Ver
    Office 365
    Posts
    6

    SortBy & Filter Formula Trouble

    Hello, I have a roster I would like to have automatically filter out and organize by Anniversary Date in ascending order. I have the roster in a table format. Was not planning on having the filtered list display in a table format.

    I've figured out the Filtering part, but when I try to add the Sortby to the formula, I get the dreaded #Value or Spill errors.

    My Filter formula I have working fine, it varies in a few places based on criteria, but you get the gist:
    =FILTER(Table28[Combined Name],(Table28[Code]=B3)*(Table28[ID]=C2),"")

    The operating formula when I try to add the sort by is:
    =SORTBY(FILTER(Table28[Combined Name],(Table28[Code]=F3)*(Table28[ID]=G2),""),Table28[Anniversary Date],1)

    I understand that I can reorganize my Roster by Anniversary Date and get the result I want, but I also want a stable filtered list, as I will reorganize my roster depending on needs.


    Also, does anyone recommend an online course focusing on formulas, complex like the above?
    Attached Files Attached Files

  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,848

    Re: SortBy & Filter Formula Trouble

    Try this:

    =LET(d,Table28[Anniversary Date],n,SORTBY(Table28[Combined Name],d,1),c,SORTBY(Table28[Code],d,1),i,SORTBY(Table28[ID],d,1),FILTER(n,(c=F3)*(i=G2),""))
    Attached Files Attached Files
    Last edited by AliGW; 05-18-2022 at 01:48 AM. Reason: Workbook attached.
    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
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: SortBy & Filter Formula Trouble

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

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: SortBy & Filter Formula Trouble

    A more robust version of my formula in-case columns are added or removed
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-21-2022
    Location
    Houston, Texas
    MS-Off Ver
    Office 365
    Posts
    6

    Re: SortBy & Filter Formula Trouble

    The Let function is new to me. I guess I see why it works, but I'm curious why it is necessary. Please don't misconstrue, I appreciate both of your solutions and I will be implementing, thank you! Is there something about a Sort/Sortby function specifically not typically cooperating with a Filter function at the same time? Perhaps something related to typically they would both return a list and that competing display is what is causing my original error?:

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: SortBy & Filter Formula Trouble

    I'm curious why it is necessary
    It isn't necessary, it just saves doing the same calculation multiple times.

    The sortby range must be the same size as the data you are sorting, with your formula you filter out some rows, but the sortby range is the entire table, so they are different sizes.

  7. #7
    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,848

    Re: SortBy & Filter Formula Trouble

    What he said! Anything defined in the LET clause is calculated only once, so it is more efficient.

  8. #8
    Registered User
    Join Date
    04-21-2022
    Location
    Houston, Texas
    MS-Off Ver
    Office 365
    Posts
    6

    Re: SortBy & Filter Formula Trouble

    Thank you both again! After googling I had thought it was something about the same size being necessary, but I discounted that as I thought since my columns were the same size it shouldn't be an issue.

  9. #9
    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,848

    Re: SortBy & Filter Formula Trouble

    Glad to help.

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: SortBy & Filter Formula Trouble

    Glad to help & thanks for the feedback.

  11. #11
    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,848

    Re: SortBy & Filter Formula Trouble

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Dynamic formula range for SORTBY and INDEX/XMATCH into a pivot table
    By Bloodraven in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-01-2022, 08:14 AM
  2. [SOLVED] Cannot use SORTBY when cells hidden
    By NicBKK in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-06-2022, 09:59 AM
  3. [SOLVED] SORTBY on many columns
    By NicBKK in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-06-2022, 12:01 AM
  4. Combining FILTER and SORTBY formulas
    By Ctromb in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-10-2021, 09:39 AM
  5. [SOLVED] SortBy + Filter Formula
    By ionelz in forum Excel General
    Replies: 9
    Last Post: 10-09-2021, 06:56 AM
  6. [SOLVED] Sort data using filter or sortby function (excel 365)
    By sunboy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-25-2021, 04:36 AM
  7. Inserting SORTBY formula in range does not work
    By ABSTRAKTUS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2020, 11:41 AM

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