Today, we want to com­bine all val­ues from the same group into one cell. Let’s go.

Com­bine all val­ues with­in group with delim­iter | Excel Pow­er Query 03

In our exam­ple, we want to com­bine all pub­lish­ers. It means that we’re doing an oper­a­tion reverse to the one in the pre­vi­ous post. This time, we want to go from this table (Fig. 1):

 Source table
Fig. 1 Source table

to this table (Fig. 2):

Target table
Fig. 2 Tar­get table

We can do it with Pow­er Query. First, select the table. Then, go to the Data tab and select the From Table/Range com­mand (Fig. 3).

 Going to Power Query
Fig. 3 Going to Pow­er Query

We can see that we have our two columns. The first thing we want to do is group our pub­lish­ers. Let’s select the Pub­lish­er head­er, then go to the Home tab and then Group By com­mand. In the new win­dow, we can see that we are group­ing by the Pub­lish­er col­umn. We still need a new aggre­ga­tion. Let’s change the Oper­a­tion bar into All Rows and write ‘Series’ in the New col­umn name bar. We can­not change any­thing in the Col­umn bar. Let’s press OK (Fig. 4).

Group By window
Fig. 4 Group By window

Now, we have the Pub­lish­ers group, and in the cells from the Series col­umn, we have all rows from the pre­vi­ous stage. The whole table is in one, sin­gle cell (Fig. 5).

Whole table in one cell
Fig. 5 Whole table in one cell

How­ev­er, we don’t need the whole table, which con­sists of two columns. We only need the Series col­umn. We can change it by mod­i­fy­ing the code. Let’s go the View tab, and let’s check whether the For­mu­la bar is ticked. If it is so, we can start mod­i­fy­ing the code in the for­mu­la bar (Fig. 6).

Going to the Formula bar
Fig. 6 Going to the For­mu­la bar

Look­ing at the code, we can see that we don’t want to choose under­score for each step. It means that we need only one col­umn. That’s why we must write ‘Series’ in the code (1). Now, let’s delete the type from the code (2) and write ‘type as list’. It’s impor­tant to write ‘list’ with a low­er­case (Fig. 7). And we see that we have only lists when we click on any of the Series cells. 

 Code modification
Fig. 7 Code modification

Now, as Pow­er Query treats val­ues as a list, we can extract them by using the Extract Val­ues option (Fig. 8).

Extracting values
Fig. 8 Extract­ing values

We are extract­ing the val­ues by com­bin­ing them with a delim­iter. We want to use a com­ma and a space, so let’s select the Cus­tom option first and then write what we want (Fig. 9). Let’s close it with OK.

Delimiter
Fig. 9 Delimiter

Now, we can see that we com­bined all Series names into one cell for each pub­lish­er. We can now go to the Home tab, then Close & Load com­mand, and press the Close & Load to option (Fig. 10).

Loading data to Excel
Fig. 10 Load­ing data to Excel

Let’s select the Table and the Exist­ing Work­sheet radio but­tons in the Import Data win­dow (Fig. 11)

Data importing
Fig. 11 Data importing

We can see that all val­ues with­in one group are com­bined into one cell (Fig. 12)

Grouped values
Fig. 12 Grouped values

https://www.youtube.com/watch?v=GFHsSJXeEaA&