Need help with CONCATENATE multiple columns in table

%3CLINGO-SUB%20id%3D%22lingo-sub-2300953%22%20slang%3D%22en-US%22%3ENeed%20help%20with%20CONCATENATE%20multiple%20columns%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2300953%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWould%20like%20to%20seek%20your%20assistance%20in%20finding%20any%20easier%20method%2F%20less%20tedious%20method%20in%20concatenating%20my%20data%20to%20obtain%20what%20I%20want%3F%20Currently%2C%20my%20approach%20is%20to%20concatenate%20manually%2C%20but%20there%20is%20too%20much%20data.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Jin_Tang_0-1619595854046.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F276195i5A44AF3F3EE58E4A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Jin_Tang_0-1619595854046.png%22%20alt%3D%22Jin_Tang_0-1619595854046.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2300953%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2301235%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20CONCATENATE%20multiple%20columns%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2301235%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1039197%22%20target%3D%22_blank%22%3E%40Jin_Tang%3C%2FA%3E%26nbsp%3BPerhaps%20Power%20Query%20(PQ)%20is%20what%20you%20need.%20Are%20you%20familiar%20with%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConnect%20to%20your%20data.%20The%20merged%20cells%20in%20the%20condition%20column%20will%20be%20un-merged%20by%20PQ%2C%20by%20the%20way.%20Then%20do%20some%20clean-up%20steps%20and%20create%20the%20desired%20output.%20Note%2C%20however%2C%20that%20the%20output%20is%20grouped%2C%20based%20on%20the%20condition%20into%20%3CSTRONG%3Eone%3C%2FSTRONG%3E%20cell%20separating%20the%20elements%20by%20a%20line-feed.%20%3CEM%3EWrap%20text%3C%2FEM%3E%20applied%20to%20column%20%26nbsp%3BA%20in%20the%20%22output%22%20sheet%20to%20see%20the%20impact%20of%20the%20line%20feeds.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2301341%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20CONCATENATE%20multiple%20columns%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2301341%22%20slang%3D%22en-US%22%3EHi%20Riny%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20the%20help.%3CBR%20%2F%3EHowever%20for%20the%20example%20of%20having%202%20different%20inputs%20for%20the%20same%20conditions%2C%20this%20doesn't%20seem%20to%20work.%3CBR%20%2F%3E%3CBR%20%2F%3EUsing%20the%20example%20i%20listed%3CBR%20%2F%3Ex1%20is%20the%20name%20of%20the%20person%2C%20x2%20is%20the%20address%2C%20x3%20is%20the%20telephone%2C%20x4%20is%20the%20company%2C%20etc%20while%20condition%20a%20is%20the%20capital%3CBR%20%2F%3Eand%20i%20have%20y1%2C%20y2%2C%20y3%2C%20which%20are%20detail%20of%20another%20group%20while%20they%20are%20still%20group%20under%20the%20same%20condition%20a.%3CBR%20%2F%3Ethen%20PQ%20doesnt%20really%20solve%20this%20problem%2C%20since%20they%20will%20group%20all%20of%20them%20up%20due%20to%20the%20condition%20A%3CBR%20%2F%3E%3CBR%20%2F%3EWould%20there%20be%20any%20other%20ways%2C%20i.e.%20via%20VBA%20to%20concatenate%20the%20number%20of%20column%20based%20on%20the%20merged%20cell%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2301460%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20CONCATENATE%20multiple%20columns%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2301460%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1039197%22%20target%3D%22_blank%22%3E%40Jin_Tang%3C%2FA%3E%26nbsp%3BOkay.%20With%20a%20few%20extra%20steps%20in%20PQ%20you%20can%20group%20it%20as%20desired.%20See%20attached.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2305116%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20help%20with%20CONCATENATE%20multiple%20columns%20in%20table%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2305116%22%20slang%3D%22en-US%22%3EHi%20Riny%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20been%20trying%20and%20I%20have%20an%20issue%20when%20merging%20the%20queries.%20How%20were%20you%20able%20to%20merge%20when%20the%20number%20of%20columns%20of%20%22Custom%22%20does%20not%20match%20the%20number%20of%20columns%20of%20%22Index%22%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20was%20the%20formula%20that%20you%20used%3CBR%20%2F%3E%3D%20Table.NestedJoin(%23%22Grouped%20Rows%22%2C%20%7B%22Custom%22%7D%2C%20%23%22Table1-copy%22%2C%20%7B%22Index%22%7D%2C%20%22Table1-copy%22%2C%20JoinKind.LeftOuter)%3CBR%20%2F%3E%3CBR%20%2F%3EI%20tried%20mimicking%20it%20on%20my%20data%20and%20the%20table%20display%20always%20shows%20null%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi All

 

Would like to seek your assistance in finding any easier method/ less tedious method in concatenating my data to obtain what I want? Currently, my approach is to concatenate manually, but there is too much data.

Jin_Tang_0-1619595854046.png

 

Thank you.

6 Replies

@Jin_Tang Perhaps Power Query (PQ) is what you need. Are you familiar with that?

 

Connect to your data. The merged cells in the condition column will be un-merged by PQ, by the way. Then do some clean-up steps and create the desired output. Note, however, that the output is grouped, based on the condition into one cell separating the elements by a line-feed. Wrap text applied to column  A in the "output" sheet to see the impact of the line feeds.

Hi Riny

Thanks for the help.
However for the example of having 2 different inputs for the same conditions, this doesn't seem to work.

Using the example i listed
x1 is the name of the person, x2 is the address, x3 is the telephone, x4 is the company, etc while condition a is the capital
and i have y1, y2, y3, which are detail of another group while they are still group under the same condition a.
then PQ doesnt really solve this problem, since they will group all of them up due to the condition A

Would there be any other ways, i.e. via VBA to concatenate the number of column based on the merged cell?

@Jin_Tang Okay. With a few extra steps in PQ you can group it as desired. See attached.

 

Hi Riny

I have been trying and I have an issue when merging the queries. How were you able to merge when the number of columns of "Custom" does not match the number of columns of "Index"?

This was the formula that you used
= Table.NestedJoin(#"Grouped Rows", {"Custom"}, #"Table1-copy", {"Index"}, "Table1-copy", JoinKind.LeftOuter)

I tried mimicking it on my data and the table display always shows null

@Jin_Tang If you go through the applied steps, one-by-one you should be able to follow and replicate it in your own file. 

First, I add an index column, Then I add a Custom column that checks if there is a value in the "Condition" column. If so, then return the index value. If not then null.  Now I have a column with the index number on each row that has a "Condition". Next step is to fill down this Custom column. This "labels" all rows that belong together with the the same index number. Thus, creating rows that can be grouped by 0,4,11,15 and 20. After cleaning-up a bit, the rows are grouped and the data gets concatenated into one cell using Text.Combine and a line-feed "#(lf)"

I took a copy of the first query up to the "Added Index" step. Now I can merge the Custom column in the first query with the Index column in the copied query. So, Custom 0 matches Index 0 which will return condition "a". Custom 4 matches Index 4 which will return condition "b" and so on.

 

If you can't get it to work, perhaps better if you upload the file containing your attempts to replicate this. That would make it easier to diagnose.

Hi Riny

Thanks for your help! I understood where i went wrong.