+ Reply to Thread
Results 1 to 7 of 7

Aggregate results from multiple rows

  1. #1
    Registered User
    Join Date
    07-26-2017
    Location
    Budapest
    MS-Off Ver
    MS 2010
    Posts
    3

    Question Aggregate results from multiple rows

    Hi Community!

    First post here, as I am super desperate to find a solution to this (spent over 2 hours already to try to find a solution)...

    You may find attached my Excel file with representative data.

    The raw data:
    I have a bunch of shortcodes (can repeat /not unique) and a bunch of names (not unique) next to them.

    The desired result:
    I would like to have one name per row with all shortcodes next to the name as an aggregated listing.

    The problem:
    I tried to do it with an IF function, unfortunately no positive result. It looked something like this:
    if ("shortcode" equals "shortcode below") then take the aggregated value from the cell above, as nothing needs to be added. If false, then take the value of the cell above and add the "shortcode below".
    This would be cool if I could disregard the names and distributions to the names. However, I would need a name-specific data field, not an overall aggregated one.

    I would be super-thankful if someone could help me.
    In the file you can also find the desired result and how the raw data looks like at the moment.

    Thanks for your kind help in advance,
    Kyba

    EDIT1:
    Maybe this helps a bit: shortcode column has a fixed width for all data of 5. (two letters + 3 number)
    Attached Files Attached Files
    Last edited by Kyba; 07-26-2017 at 08:46 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,054

    Re: Aggregate results from multiple rows

    I'm not clear if you just want the unique codes... The best way to achieve this is using a UDF

    Code, pasted into a module (save as .xlsm):

    Please Login or Register  to view this content.
    Formula (E4):
    =IFERROR(INDEX($B$4:$B$13,MATCH(0,INDEX(COUNTIF($E$3:$E3,$B$4:$B$13),0),0)),"")

    Array Formula (F4):
    =concatall(IF($B$4:$B$13=E4,$A$4:$A$13,""),", ")


    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...

    If you need UNIQUE results, different code is needed.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    07-26-2017
    Location
    Budapest
    MS-Off Ver
    MS 2010
    Posts
    3

    Re: Aggregate results from multiple rows

    Hi Glenn!

    Thank you so much for your quick response.
    The instructions are easy to follow and the formula and macro work like a charm!

    As you guessed it - sorry for not mentioning this in the original request - I would need one shortcode only once next to a name. It can happen that a code is distributed to more names at once, but one name should only have one code once in the F column.
    Maybe there is a way to remove duplicates within a cell for each row?

    Your reply is appreciated,
    Kyba

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Aggregate results from multiple rows

    ARRAY formula in H4 for Name , then drag down.
    Please Login or Register  to view this content.
    ARRAY formula should be confirmed with Ctrl+Shift+Enter together
    For code column UDF "ConcatenateSpecial" is given. Pl see File.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,054

    Re: Aggregate results from multiple rows

    Of course...

    Code:

    Please Login or Register  to view this content.
    Formula (array entered):

    =concatall(IF($B$4:$B$13=E4,$A$4:$A$13,""),", ",TRUE)
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-26-2017
    Location
    Budapest
    MS-Off Ver
    MS 2010
    Posts
    3

    Re: Aggregate results from multiple rows

    Hi Glenn!

    Thank you for the solution. Works perfectly.

    Kind regards,
    Kyba

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,054

    Re: Aggregate results from multiple rows

    You're welcome.



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

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Search Multiple Columns and Rows - Show results in Multiple columns and rows
    By heykeighley in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 08-12-2015, 10:16 AM
  2. Aggregate function to number rows
    By cdumper in forum Excel General
    Replies: 9
    Last Post: 09-27-2014, 07:22 PM
  3. [SOLVED] Using Aggregate results in #NAME? error
    By y_not in forum Excel General
    Replies: 6
    Last Post: 07-30-2014, 08:26 AM
  4. [SOLVED] Need to display ONLY filtered results by use of a Sum, Vlookup and aggregate?
    By shameus in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-27-2014, 04:02 PM
  5. [SOLVED] Is it possible to lookup multiple values and return multiple rows of results?
    By justin11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-20-2013, 12:02 PM
  6. Aggregate multiple values into one cell based on multiple criteria using VBA
    By jwestover1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2013, 01:17 PM
  7. copying an aggregate average function down multiple rows
    By sarah.grady in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-24-2012, 11:49 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