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
kkg1991
Regular Visitor

How to Merge two rows with nulls and data (half of rows is filled with data and half with nulls)

Hello Everyone,

 

Is there any way to merge two rows which having nulls and data in both rows

for ex:

rows looks like this

code       name             yr            values                            code                  name               lastyr             lastyrvalues

xyz         abc               2018         123                               null                       null               null                  null

null         null              null            null                             xyz                        abc                 2017               345

 

I want to merge those two columns into one single column and the final row I'm looking for is

code          name        yr            values                  code         name      lastyr            lastyrvalues

xyz            abc           2018       123                     xyz              abc           2017             345

 

Is there any way to get the result like this in Power BI Query Edit Window I tried with transposing entire table and merging two columns with a delimiter and pivoting and unpoviting but didn't get exact outcome what I'm looking for.

 

any help is appreciated.

 

Thanks   

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @kkg1991,

Based on my test, you can refer to below steps in Query Editor:

1.Use the “Transpose” function to transpose your data.

1.1.PNG

2.Use the “Custom Column” function to merge the Column2 and the Column3.

Custom=[Column2]&[Column3]

1.2.PNG

3.Remove the Column2 and the Column3.

1.3.PNG

4.Transpose your data again and use the "Use First Row as Headers" function to set your headers. Now you can get the result.

1.4.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/8ch5acxfbta3epx/How%20to%20Merge%20two%20rows%20with%20nulls%20and%20data....

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-danhe-msft
Employee
Employee

Hi @kkg1991,

Based on my test, you can refer to below steps in Query Editor:

1.Use the “Transpose” function to transpose your data.

1.1.PNG

2.Use the “Custom Column” function to merge the Column2 and the Column3.

Custom=[Column2]&[Column3]

1.2.PNG

3.Remove the Column2 and the Column3.

1.3.PNG

4.Transpose your data again and use the "Use First Row as Headers" function to set your headers. Now you can get the result.

1.4.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/8ch5acxfbta3epx/How%20to%20Merge%20two%20rows%20with%20nulls%20and%20data....

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Daniel for your help. 

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful reply as Answered?

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.