+ Reply to Thread
Results 1 to 9 of 9

Filter function and sum totalling by column values

  1. #1
    Registered User
    Join Date
    06-27-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365 Excel v2108
    Posts
    4

    Filter function and sum totalling by column values

    I've searched for similar posts to my question but hard to find answers because I keep getting links to pages that explain how to subtotal a filtered list (as in a table list) and not when using the FILTER function and so hoping someone can help.

    I have a structured table called Tbl_Data (Sample also attached)

    Key Cost QtyOld QtyNew QtyDiff Inclusions
    AAA 1.5 10 4 6 Include
    AAA 1.5 3 6 -3 Include
    BBB 2.5 5 7 -2 Include
    CCC 3.5 4 3 1 Include
    AAA 1.5 9 4 5 Exclude
    BBB 2.5 2 9 -7 Include
    BBB 2.5 15 6 9 Exclude
    CCC 3.5 8 2 6 Include


    FILTER sample.xlsb


    I need to use something other than a pivot and I'm attempting to use the filter function to output/list a subset of data where the filter will only use rows with "Include" and then aggregate or sum the total by each key.

    The following formula will give me a list/table with the first, 3rd, 4th & 5th columns where [Inclusions] = "Include"

    =FILTER(INDEX(Tbl_Data,SEQUENCE(ROWS(Tbl_Data)),{1,3,4,5}),Tbl_Data[Inclusions]="Include",0)

    The problem I need help with is aggregating or totalling the QtyOld, QtyNew & QtyDiff by each key so as to end up with the following;

    Key QtyOld QtyNew QtyDiff
    AAA 13 10 3
    BBB 7 16 -9
    CCC 12 5 7

    If that's too difficult then can I just get QtyDiff totalled by each Key ? ;
    Key QtyDiff
    AAA 3
    BBB -9
    CCC 7


    Can either of these be done with Filter ?

    Thanks in advance.
    Gavin
    Last edited by GavCol; 11-04-2022 at 02:26 AM.

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

    Re: Filter function and sum totalling by column values

    Try this:

    =LET(u,UNIQUE(Tbl_Data[Key]),qo,SUMIFS(Tbl_Data[QtyOld],Tbl_Data[Key],u,Tbl_Data[Inclusions],"Include"),qn,SUMIFS(Tbl_Data[QtyNew],Tbl_Data[Key],u,Tbl_Data[Inclusions],"Include"),qd,SUMIFS(Tbl_Data[QtyDiff],Tbl_Data[Key],u,Tbl_Data[Inclusions],"Include"),CHOOSE({1,2,3,4},u,qo,qn,qd))

    Your forum profile is clearly way out-of-date (Excel 2003) - please update it NOW.
    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.
    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 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,780

    Re: Filter function and sum totalling by column values

    Or a tiny bit shorter:

    =LET(u,UNIQUE(Tbl_Data[Key]),tbi,Tbl_Data[Inclusions],i,"Include",qo,SUMIFS(Tbl_Data[QtyOld],Tbl_Data[Key],u,tbi,i),qn,SUMIFS(Tbl_Data[QtyNew],Tbl_Data[Key],u,tbi,i),qd,SUMIFS(Tbl_Data[QtyDiff],Tbl_Data[Key],u,tbi,i),CHOOSE({1,2,3,4},u,qo,qn,qd))
    Attached Files Attached Files

  4. #4
    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,780

    Re: Filter function and sum totalling by column values

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

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

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

    Re: Filter function and sum totalling by column values

    Another way:

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

  6. #6
    Registered User
    Join Date
    06-27-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365 Excel v2108
    Posts
    4

    Re: Filter function and sum totalling by column values

    Quote Originally Posted by HansDouwe View Post
    Another way:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    HansDouwe, Thank you for the example.
    I would love to try this one but unfortunately while I have the LET function, I don't have Lambda available in my current version yet. I am looking forward to using it though Thanks again !

  7. #7
    Registered User
    Join Date
    06-27-2011
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365 Excel v2108
    Posts
    4

    Re: Filter function and sum totalling by column values

    Quote Originally Posted by AliGW View Post
    Or a tiny bit shorter:

    =LET(u,UNIQUE(Tbl_Data[Key]),tbi,Tbl_Data[Inclusions],i,"Include",qo,SUMIFS(Tbl_Data[QtyOld],Tbl_Data[Key],u,tbi,i),qn,SUMIFS(Tbl_Data[QtyNew],Tbl_Data[Key],u,tbi,i),qd,SUMIFS(Tbl_Data[QtyDiff],Tbl_Data[Key],u,tbi,i),CHOOSE({1,2,3,4},u,qo,qn,qd))
    AliGW, Thank you muchly !! That worked a treat once I transposed it to my original data set.
    I've been meaning to get stuck into using the Let function for a while now but just hadn't gotten around to it yet. Had not considered it at all for this solution !.
    Thanks again (and profile now updated)

    Cheers
    Gav

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

    Re: Filter function and sum totalling by column values

    I don't have Lambda available in my current version yet
    Thanks for your feedback and rep .

    I think you have the Semi-Annual Enterprise Channel.
    If you succeed in downloading version V2208, you will also have access to the new Excel functions.

    Furthermore, I expect that the regular version will be available for your Channel in mid-January 2023.
    Attached Images Attached Images

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

    Re: Filter function and sum totalling by column values

    You're welcome - thanks for the rep.

+ 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. Replies: 12
    Last Post: 09-23-2019, 04:30 PM
  2. Replies: 6
    Last Post: 10-16-2014, 08:42 AM
  3. Replies: 6
    Last Post: 06-01-2012, 07:27 AM
  4. [SOLVED] Sum Function not totalling properly
    By jo15765 in forum Excel General
    Replies: 7
    Last Post: 05-15-2012, 10:27 AM
  5. Replies: 15
    Last Post: 01-03-2012, 01:23 PM
  6. Totalling grouped values
    By Dbeethekidd in forum Excel General
    Replies: 3
    Last Post: 10-30-2011, 11:02 AM
  7. [SOLVED] Totalling unique values
    By Stumped in forum Excel General
    Replies: 2
    Last Post: 07-27-2005, 10:05 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