+ Reply to Thread
Results 1 to 9 of 9

Group by using filter array and then join columnn and rows

  1. #1
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Group by using filter array and then join columnn and rows

    Hi

    i have a table and want to filter by conditions, then group them by one column, then concatenate the remaining columns, then text join the rows and all of this in one single formual
    So far i am able to do all the things except the Group by part

    I am able to use the Powerquery to get the desired results.
    I figured out how to sort and filter the data with the dynamic array formula.

    For the 21.08 and machine B I can get to this result with the arrays (formual in cell J21)

    The final result is combining rows and columns to this:
    mix=22=full=21=mix=12=full=5

    But i need this one
    mix=34, full=26

    SO the issues I can not solve by my own are:
    How can i sum the scrap amount by the reasons for my selection in the array

    So from this table
    mix 22
    full 21
    mix 12
    full 5

    to this one

    mix 34
    full 26



    Thanks
    Attached Files Attached Files
    Last edited by hansolu; 08-27-2021 at 04:56 AM. Reason: solved

  2. #2
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Group by using filter array and then join columnn and rows

    Please see formula in cell [C23].

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Row row row your boat
    Gently down the stream

  3. #3
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Group by using filter array and then join columnn and rows

    Ohh, thats a bit easier than my formula, thanks a lot.

    I forgot to mention one point, its in my formula, how can i sort by value in your solution?
    e.g.
    mix=13,test=55,full=5 should be
    test=55,mix=13,full=5

    So starting with the highest values descending.


    And one thing, for my understanding of your formula:
    Sumifs is just going trough the tabel and create an array with the summarized values.
    The part TEXTJOIN(", ",,IF(x,UNIQUE(DATA[Reason])&"="&x,"")) is not clear for me, the if part.
    I read the formula, go through the array from sumifs, if there is a value, take the unique value from Data[Reason] and add the = and value x.
    But UNIQUE(DATA[Reason] is going back to the initial table, how can this link to the sumifs value for the single reason?



    Thanks a lot
    Last edited by hansolu; 08-23-2021 at 01:44 AM.

  4. #4
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Group by using filter array and then join columnn and rows

    Please try this formula to get sort by value result:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by AliGW; 08-23-2021 at 02:27 AM. Reason: PLEASE don't quote unnecessarily!

  5. #5
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Group by using filter array and then join columnn and rows

    refer to your question in #3:
    TEXTJOIN(", ",,IF(x,UNIQUE(DATA[Reason])&"="&x,""))

    Let's take 21/8/2021, Machine B as an example:

    variable x in LET formula will generate the array [34,0 ,26]

    thus, IF(x, means IF({34,0,26}, which has the same effect as IF({true,false,true},


    UNIQUE(DATA[Reason]) produces an array, which is used as a criteria parameter of SUMIFS.

    You can try the below formula for a better understanding:

    =SUMIFS(DATA[Scrap],DATA[Date],J10,DATA[Machine],K10,DATA[Reason],{"test";"full";"nothing"})

  6. #6
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Group by using filter array and then join columnn and rows

    Hi,

    thanks, I understand that so far, what i dont understand is the order of the arrays.

    x in let create the [34,0 ,26] (based on the criterias selected)
    DATA[Reason],{"test";"full";"nothing"} is not linked to the order of the array in x, as it goes to the whole table and create the unique list DATA[Reason],UNIQUE(DATA[Reason])
    How do we know that 34 is test, 0 is full and 26 is nothing if the order is not the same inside the x and criteria array?

    I modified the formula a bit, easier to read for me and some small modifications.


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


    Problem is that the scrap reason can contain two words (like: too much), in this case your formula substitute wrong. I filtered the sorted array to get rid of empty rows, then concatenate the single columns and then textjoin the result

    Looks good to me, what do you think?

    Thanks for your help!!

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Group by using filter array and then join columnn and rows

    Please try
    =LET(ur,UNIQUE(D3:D15),sm,SUMIFS(C3:C15,A3:A15,J10,B3:B15,K10,C3:C15,">"&Limit,D3:D15,ur),TEXTJOIN(", ",,TEXT(SORT(sm,,-1),""""&SORTBY(ur,sm,-1)&"""=0;;")))


    PQ

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-15-2013
    Location
    Singapore, Melbourne
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Group by using filter array and then join columnn and rows

    That's good. Thank you for sharing your idea.

  9. #9
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Group by using filter array and then join columnn and rows

    HI,
    i tryed the alternative way for the powerquery, its really easier to do but a bit more difficult to understand. Thanks

+ 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] problem with join in array
    By daboho in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-02-2018, 11:32 AM
  2. Trying to filter rows in an array using a list as reference
    By trajayee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2016, 06:42 PM
  3. [SOLVED] Using Array(s) to filter 13k+rows with 600+ keywords
    By robkrouse in forum Excel General
    Replies: 5
    Last Post: 01-31-2016, 04:06 AM
  4. Happy to join this group!
    By Luis Callejas in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 08-20-2014, 08:46 PM
  5. Replies: 1
    Last Post: 02-10-2014, 10:26 PM
  6. Glad to join the group
    By Tom Rynearson in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 08-21-2013, 09:10 PM
  7. Feeling very great to join this group.
    By shivaj in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 02-21-2013, 01:48 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