Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Data_N00b
Frequent Visitor

Joining and Splitting Cells with Multiple Lines

Hello,

 

I have searched around and couldn't find a similar question.;It might be how I am phrasing my question...

 

I am trying to join data into a new column. The 2 columns have multiple lines within a cell. When I make a column with a formula, it takes the contents of the first column followed by the second column. I am wanting to take the first line of 1 column and join it with the first line in the 2nd column, then seperate the new column by each line.

 

Please see below for an example of what I am trying to achieve. I know how to split cells into multiple rows for each line with in a cell, but I am having trouble joining the Xth line of each cell in one column to the xth line from another column. 

 

Data_N00b_0-1677507720782.png

 

 

Data - Current State:  
Column AColumn B 
A3 - Line 1
A3 - Line 2
A3 - Line 3
B3 - Line 1
B3 - Line 2
B3 - Line 3
 
   
   
   
   
Desired Results:  
A3 - Line 1 B3 - Line 1  
A3 - Line 2 B3 - Line 2  
A3 - Line 3 B3 - Line 3  
1 ACCEPTED SOLUTION
Data_N00b
Frequent Visitor

I got a solution from a coworker. The solution uses text splits by line feeds (Text.Split M Code), creating a table from columns (Table.FromColumns M code), expanding a column, and merging columns (using Text.Combine M code)

 

Below is the table that served as an example.

 

Data_N00b_0-1677676712381.png

 

Steps for transforming the table:

 

  1. Add a custom colun and do a text split by a line break/line feed: =Text.Split([Column A],"#(lf)")
  2. Repeat Step 1 for Column B.
  3. Create another custom column, You will create a Table from the splitting of Columns A and B. This basically creates a table within a table. This column was called Custom.
    • =Table.FromColumns({[Split Column A],[Split Column B]},{"Column A New", "Column B New"})
  4. Expand the the "Custom Colum" (created in Step 3)
  5. Data_N00b_1-1677677078403.png

     

  6. Create a Custom Column, and merge the contents "=Text.Combine({[Column A New], " ", [Column B New]})"

Final Results:

Data_N00b_0-1677677247667.png

 

 

 

View solution in original post

4 REPLIES 4
Data_N00b
Frequent Visitor

I got a solution from a coworker. The solution uses text splits by line feeds (Text.Split M Code), creating a table from columns (Table.FromColumns M code), expanding a column, and merging columns (using Text.Combine M code)

 

Below is the table that served as an example.

 

Data_N00b_0-1677676712381.png

 

Steps for transforming the table:

 

  1. Add a custom colun and do a text split by a line break/line feed: =Text.Split([Column A],"#(lf)")
  2. Repeat Step 1 for Column B.
  3. Create another custom column, You will create a Table from the splitting of Columns A and B. This basically creates a table within a table. This column was called Custom.
    • =Table.FromColumns({[Split Column A],[Split Column B]},{"Column A New", "Column B New"})
  4. Expand the the "Custom Colum" (created in Step 3)
  5. Data_N00b_1-1677677078403.png

     

  6. Create a Custom Column, and merge the contents "=Text.Combine({[Column A New], " ", [Column B New]})"

Final Results:

Data_N00b_0-1677677247667.png

 

 

 

Arul
Super User
Super User

@Data_N00b ,

you need to add one more column to get the desired result,

1. In power query editor go to add column and click custom column and enter the below formula by changing the necessary column names,

[Column A] &" "& [Column B]

Arul_0-1677510739911.png

2. Desired result,

Arul_1-1677510776928.png

Thanks,

Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Hi Arul,

 

Thank you for helping me. 

 

One of the problems I have is that there are multiple lines in the 2 columns. When I try the & symbol it just takes Colunm A contents and joins contents from Column B right after Column A's contents.

 

@Data_N00b ,

sorry I did not understand but the above formula should work for all the lines in two columns.

Thanks,

Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.