SOLVED

Excel 2016 power Query how to consolidate data into one common row

%3CLINGO-SUB%20id%3D%22lingo-sub-1408748%22%20slang%3D%22en-US%22%3EExcel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1408748%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20a%20customer%20that%20likes%20the%20output%20but%20would%20like%20common%20rows%20to%20be%20consolidated%20into%20one%20row.%26nbsp%3B%20Example%3A%203%20rows%20have%20the%20same%20%22Loop%20Number%22%20but%20columns%20%22IO1-IO8%20Loop%20Number%22%20may%20have%20separate%20data.%3C%2FP%3E%3CP%3EIs%20it%20possible%20to%20do%20or%20do%20I%20need%20to%20read%20into%20an%20array%20to%20write%20out%20a%20new%20table%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22recho_0-1590070001650.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193573i52386AC34D901229%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22recho_0-1590070001650.png%22%20alt%3D%22recho_0-1590070001650.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1408748%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1408863%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1408863%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F578739%22%20target%3D%22_blank%22%3E%40recho%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20reference%20on%20the%20query%20and%3C%2FP%3E%0A%3CP%3E1)%20Merge%20all%20NNN%20Loop%20Number%20columns%20into%20one%20column%2C%20let%20say%20Merged%3C%2FP%3E%0A%3CP%3E2)%20Group%20By%20Loop%20Number%20with%20aggregating%20Merged%20column%20on%20Sum%3C%2FP%3E%0A%3CP%3E3)%20Change%20in%20formula%20bar%20List.Sum(%5BMerged%5D)%20on%20Text.Combine(%5BMerged%5D%2C%22%2C%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EReference%20on%20initial%20query%20once%20more%20and%20merge%20with%20previous%20one%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1409313%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1409313%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20followed%20up%20to%20step%203%20but%20some%20of%20the%20rows%20have%20more%20delimiters%20that%20the%208%20columns%20merged.%20When%20I%20split%20the%20merged%20column%20I%20end%20up%20with%2024%20columns%20instead%20of%20the%208%20original%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22recho_0-1590078230978.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193613i60A536B745D56AEB%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22recho_0-1590078230978.png%22%20alt%3D%22recho_0-1590078230978.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1409368%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1409368%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F578739%22%20target%3D%22_blank%22%3E%40recho%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20mean%20that%20delimiter%20sign%20is%20within%20texts%2C%20you%20may%20use%20any%20other%20one%2C%20e.g.%20%22%3CSEP%3E%22%20both%20on%20merging%20the%20columns%20and%20Text.Combine().%3C%2FSEP%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1409540%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1409540%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENo%20issue%20with%20delimiter..%20what's%20happening%20is%20if%20a%20common%20row%20has%203%20loop%20number%20columns%20filled%2C%20then%20that%20is%208x3%20%3D%2024%20columns%20are%20created%20(appended)%20without%20order%2C%20and%20not%20merged%20for%20the%20original%208%20columns%20%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22recho_0-1590082410633.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193635i4AC5A75D6B3EAEF2%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22recho_0-1590082410633.png%22%20alt%3D%22recho_0-1590082410633.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1409670%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1409670%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F578739%22%20target%3D%22_blank%22%3E%40recho%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20for%20such%20sample%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20369px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193648i7251DE9F08099528%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Eit%20shall%20be%20k2%2Ck1%20not%20k1%2Ck2%20%3F%3C%2FP%3E%0A%3CP%3EWhy%20do%20you%20have%20commas%20for%20the%20null%20values%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1409671%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%202016%20power%20Query%20how%20to%20consolidate%20data%20into%20one%20common%20row%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1409671%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMany%20Thanks%2C%20after%20tweaking%20the%20following%20worked%20(Group%20By%26nbsp%3B%20Advanced)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3D%20Table.Group(%23%22Sorted%20Rows%22%2C%20%7B%22Loop%20Number%22%7D%2C%20%7B%7B%22Sum1%22%2C%20each%20Text.Combine(%5BIO1%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20text%7D%2C%20%7B%22Sum2%22%2C%20each%20Text.Combine(%5BIO2%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20text%7D%2C%20%7B%22Sum3%22%2C%20each%20Text.Combine(%5BIO3%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20text%7D%2C%20%7B%22Sum4%22%2C%20each%20Text.Combine(%5BIO4%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20none%7D%2C%20%7B%22Sum5%22%2C%20each%20Text.Combine(%5BIO5%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20none%7D%2C%20%7B%22Sum6%22%2C%20each%20Text.Combine(%5BIO6%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20text%7D%2C%20%7B%22Sum7%22%2C%20each%20Text.Combine(%5BIO7%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20none%7D%2C%20%7B%22Sum8%22%2C%20each%20Text.Combine(%5BIO8%20Loop%20Number%5D%2C%22%2C%22)%2C%20type%20none%7D%7D)%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi,

I have a customer that likes the output but would like common rows to be consolidated into one row.  Example: 3 rows have the same "Loop Number" but columns "IO1-IO8 Loop Number" may have separate data.

Is it possible to do or do I need to read into an array to write out a new table?

recho_0-1590070001650.png

 

7 Replies
best response confirmed by recho (Occasional Contributor)
Solution

@recho 

You may reference on the query and

1) Merge all NNN Loop Number columns into one column, let say Merged

2) Group By Loop Number with aggregating Merged column on Sum

3) Change in formula bar List.Sum([Merged]) on Text.Combine([Merged],",")

 

Reference on initial query once more and merge with previous one

@Sergei Baklan 

 

I followed up to step 3 but some of the rows have more delimiters that the 8 columns merged. When I split the merged column I end up with 24 columns instead of the 8 original columns.

 

recho_0-1590078230978.png

 

@recho 

If you mean that delimiter sign is within texts, you may use any other one, e.g. "<SEP>" both on merging the columns and Text.Combine().

@Sergei Baklan 

No issue with delimiter.. what's happening is if a common row has 3 loop number columns filled, then that is 8x3 = 24 columns are created (appended) without order, and not merged for the original 8 columns :

recho_0-1590082410633.png

 

@recho 

So, for such sample

image.png

it shall be k2,k1 not k1,k2 ?

Why do you have commas for the null values?

@Sergei Baklan 

Many Thanks, after tweaking the following worked (Group By  Advanced):

 

= Table.Group(#"Sorted Rows", {"Loop Number"}, {{"Sum1", each Text.Combine([IO1 Loop Number],","), type text}, {"Sum2", each Text.Combine([IO2 Loop Number],","), type text}, {"Sum3", each Text.Combine([IO3 Loop Number],","), type text}, {"Sum4", each Text.Combine([IO4 Loop Number],","), type none}, {"Sum5", each Text.Combine([IO5 Loop Number],","), type none}, {"Sum6", each Text.Combine([IO6 Loop Number],","), type text}, {"Sum7", each Text.Combine([IO7 Loop Number],","), type none}, {"Sum8", each Text.Combine([IO8 Loop Number],","), type none}})

@recho , you are welcome, glad to know you sorted this out