Table consolidation help

patchkek

New Member
Joined
Sep 4, 2018
Messages
9
Hello,

I have a table that looks like this

Customer NumberDate VisitedRating
15/21/20181
22/7/20174
34/2/20182
25/6/20175
49/8/20174
511/25/20172
43/2/20175
66/8/20183
77/22/20182
72/16/20181
42/1/20184
312/14/20175
212/1/20171
18/8/20172
29/6/20173
35/6/20172
52/16/20184
42/7/20175
27/22/20182
58/19/20183
61/16/20184
110/17/20174
27/5/20174
36/6/20172

<colgroup><col><col><col></colgroup><tbody>
</tbody>



And I would like to transpose / consolidate / combine to look like this:

Customer NumberDate VisitedRatingDate Visited2Rating3Date Visited4Rating5Date Visited6Rating7Date Visited8Rating9
22/7/2017412/1/201719/6/201737/22/201827/5/20174
34/2/2018212/14/201755/6/201726/6/20172
49/8/201743/2/201752/1/201842/7/20175

<colgroup><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>


Any help/advise you can offer?

Thanks so much!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
at first glance you can try with PowerQuery

Customer NumberDate Visited.1Rating.1Date Visited.2Rating.2Date Visited.3Rating.3Date Visited.4Rating.4Date Visited.5Rating.5Date Visited.6Rating.6
1​
08/08/2017​
2​
17/10/2017​
4​
21/05/2018​
1​
2​
07/02/2017​
4​
06/05/2017​
5​
05/07/2017​
4​
06/09/2017​
3​
01/12/2017​
1​
22/07/2018​
2​
3​
06/05/2017​
2​
06/06/2017​
2​
14/12/2017​
5​
02/04/2018​
2​
4​
07/02/2017​
5​
02/03/2017​
5​
08/09/2017​
4​
01/02/2018​
4​
5​
25/11/2017​
2​
16/02/2018​
4​
19/08/2018​
3​
6​
16/01/2018​
4​
08/06/2018​
3​
7​
16/02/2018​
1​
22/07/2018​
2​

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer Number", Int64.Type}, {"Date Visited", type date}, {"Rating", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Customer Number", Order.Ascending}, {"Date Visited", Order.Ascending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"Customer Number"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Date Visited", each Table.Column([Count],"Date Visited")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Date Visited", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "Rating", each Table.Column([Count],"Rating")),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Rating", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values1", "Date Visited", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Date Visited.1", "Date Visited.2", "Date Visited.3", "Date Visited.4", "Date Visited.5", "Date Visited.6"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date Visited.1", type date}, {"Date Visited.2", type date}, {"Date Visited.3", type date}, {"Date Visited.4", type date}, {"Date Visited.5", type date}, {"Date Visited.6", type date}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1", "Rating", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Rating.1", "Rating.2", "Rating.3", "Rating.4", "Rating.5", "Rating.6"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Rating.1", Int64.Type}, {"Rating.2", Int64.Type}, {"Rating.3", Int64.Type}, {"Rating.4", Int64.Type}, {"Rating.5", Int64.Type}, {"Rating.6", Int64.Type}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Changed Type2",{"Customer Number", "Count", "Date Visited.1", "Rating.1", "Date Visited.2", "Rating.2", "Date Visited.3", "Rating.3", "Date Visited.4", "Rating.4", "Date Visited.5", "Rating.5", "Date Visited.6", "Rating.6"}),
    #"Removed Columns" = Table.RemoveColumns(#"Reordered Columns",{"Count"})
in
    #"Removed Columns"[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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