Power Query to Concatenate Rows With null Values

barberic5

New Member
Joined
Nov 23, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hello, I'm new to using PowerQuery and hoping to get some help with an issue I ran into. when I import data, I need to concatenate all the rows in column A and column B where the text spills over into the next row. The number of rows the values spill over varies based on the text length of the Item and the Description. I need to remove all the rows with null values and concatenate the values in column A and column B from the deleted rows with null values. So in the end there should be six rows including the headers in this example.
 

Attachments

  • Power Query Example.png
    Power Query Example.png
    45.8 KB · Views: 115

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Cannot manipulate data in a picture. Suggest you reload your data using XL2BB. If you are unfamiliar with XL2BB look in my signature for instructions.
 
Upvote 0
Cannot manipulate data in a picture. Suggest you reload your data using XL2BB. If you are unfamiliar with XL2BB look in my signature for instructions.
Sure thing, here it is:

Power Query Test Example.xlsx
ABCDE
1ITEMDESCRIPTIONQTYRATEAMOUNT
2MiniNail Kit BlackMiniNail Micro Enail Kit with Black Controller, Hybrid2$1,000.00$2,000.00
3with RainbowCoil, Rainbow Quartz/Titanium Hybrid Nail, Rainbownullnullnull
4Hybrid Nail andFlat Tip Carb Cap and Dabber, Slab Pad and Powernullnullnull
5Rainbow Flat Tip DabberCordnullnullnull
6MiniNail KitMiniNail Micro Enail Kit with Purple Controller,1$1,000.00$1,000.00
7Purple withHybrid Coil, Rainbow Quartz/Titanium Hybrid Nail,nullnullnull
8Rainbow HybridRainbow Flat Tip Carb Cap and Dabber, Slab Padnullnullnull
9Nail and Rainbow Flat Tip Dabberand Power Cordnullnullnull
10MiniNail Kit SilverMiniNail Micro Enail Kit with Silver Controller, Hybrid1$1,000.00$1,000.00
11with Silver HybridCoil, Silver Quartz/Titanium Hybrid Nail, Silver Ninjanullnullnull
12Nail and SilverSword Carb Cap and Dabber, Slab Pad and Powernullnullnull
13Ninja Sword DabberCordnullnullnull
1425mm Quartz25mm Quartz Banger with 90 Degree Bend and1$500.00$500.00
15Banger14mm Male Jointnullnullnull
16Replacement Dish Pack -Quartz Deep DishReplacement Dish Pack - Quartz Deep Dish1$500.00$500.00
Table002 (Page 1)
 
Upvote 0
I'm sure there are more direct ways, but this should do the job:

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Grouper", each if [QTY] is null then null else [Index]),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Grouper", "QTY", "RATE", "AMOUNT"}),
    #"Removed Columns" = Table.RemoveColumns(#"Filled Down",{"Index"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"QTY", "RATE", "AMOUNT", "Grouper"}, {{"Items", each Text.Combine([ITEM], " "), type text}, {"Descriptions", each Text.Combine([DESCRIPTION], " "), type text}})
in
    #"Grouped Rows"
 
Upvote 0
Solution
That did the trick, thanks so much! Is there a way to go about this with the UI instead of code?

Also, sorry for the late response. I had fallen ill and then had some work to catch up on.
 
Upvote 0
All those steps were done via the UI. :)
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top