+ Reply to Thread
Results 1 to 5 of 5

Sum Within Groups and Subgroups of Different Lengths

  1. #1
    Registered User
    Join Date
    02-01-2022
    Location
    Texas, United States
    MS-Off Ver
    Microsoft 365 Version 2112
    Posts
    2

    Unhappy Sum Within Groups and Subgroups of Different Lengths

    Hi everyone,

    I frequently work with data organized by groups and subgroups (literally, the +/- expand/collapse) and looking for a formula that can sum within each.

    The main hurdles are 1) each group or subgroup are different lengths, and 2) each can have repeating names (e.g., both Group 1 and Group 2 might have an operational costs subgroup). At the moment, my team has to manually adjust SUM and SUMIF ranges rather than having one formula that can be copied, shown in F-I in the attached demo.

    I've tried filling in each cell with its parent group and subgroup names and using xlookup or index-match, but run into the same issue that requires manually adjusting the formula to reference the right parent name.

    Any suggestions are welcome, because this takes forever with our datasets!
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Sum Within Groups and Subgroups of Different Lengths

    Would this presentation work for you?

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    22
    Column1 Column2 Totals
    23
    Group1 Sub1
    120
    24
    Group1 Sub 2
    41
    25
    Group2 Sub1
    80
    26
    Group2 Sub2
    27
    Sheet: Sheet1
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    02-01-2022
    Location
    Texas, United States
    MS-Off Ver
    Microsoft 365 Version 2112
    Posts
    2

    Re: Sum Within Groups and Subgroups of Different Lengths

    Thanks for replying! There would need to be another column (multiple items within each Sub -- need to sum the items in each Sub and the Subs in each Group), but otherwise yes, setting it up with each row filled in is fine. Does that mean you know a formula that works with that presentation?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Sum Within Groups and Subgroups of Different Lengths

    For this presentation, I did this with Power Query. Here is the Mcode and background information. For your specific requirements, I will need to try to modify. Will not get to it until later tonight. Its Happy Hour Time in the 'Boat and I am running late.

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.


    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Sum Within Groups and Subgroups of Different Lengths

    Had a minute or two. Would this work for you?

    Excel 2016 (Windows) 32 bit
    E
    F
    G
    H
    I
    22
    Column1 Column2 Column3 Totals Column4
    23
    Group1 Sub1 Item1
    120
    90
    24
    Group1 Sub1 Item2
    120
    30
    25
    Group1 Sub 2 Item1
    41
    20
    26
    Group1 Sub 2 Item2
    41
    9
    27
    Group1 Sub 2 Item3
    41
    12
    28
    Group2 Sub1 Item1
    80
    60
    29
    Group2 Sub1 Item2
    80
    4
    30
    Group2 Sub1 Item3
    80
    16
    31
    Group2 Sub2 Item1
    27
    11
    32
    Group2 Sub2 Item2
    27
    8
    33
    Group2 Sub2 Item3
    27
    2
    34
    Group2 Sub2 Item4
    27
    6
    Sheet: Sheet1

+ 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. Rank subgroups without duplicates
    By Philip63 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-24-2023, 06:07 PM
  2. Ranking values within subgroups
    By student789 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-06-2019, 01:33 AM
  3. [SOLVED] Transpose multiple cell groups of varying lengths
    By Mikestrauss35 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-25-2017, 09:24 PM
  4. Scatter Plot with SubGroups
    By wilfrid147 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-20-2015, 07:56 AM
  5. Scatter Plot with Subgroups
    By wilfrid147 in forum Excel General
    Replies: 1
    Last Post: 07-20-2015, 04:42 AM
  6. Trying to Rank within Subgroups of one column
    By gemispence in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-26-2015, 05:08 PM
  7. [SOLVED] Add running numbers within subgroups
    By joshfredericks in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-31-2015, 10:18 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