Consolidating multiple rows into one row with row data from some columns across page

Edlin59

New Member
Joined
Nov 28, 2018
Messages
7
Hello. I have multiple rows of data that I would like to consolidate into one row based on information in a number of columns. In the example 1 below I would like to consolidate all rows based on UniqueId, however would like the rows for Product & Question columns combined across the page with Answer displayed as a row under the combined columns – as per example 2.

Example 1

UniqueIdNameCol3Col4Col5Col6ProductQuestionAnswer
Name1RedDCWhiteHigh1/12/2018ProdAQ1Yes
Name1RedDCWhiteHigh1/12/2018ProdAQ2Yes
Name1RedDCWhiteHigh1/12/2018ProdAQ3Yes
Name1RedDCWhiteHigh1/12/2018ProdAQ4No
Name1RedDCWhiteHigh1/12/2018ProdAQ5No
Name1RedDCWhiteHigh1/12/2018ProdAQ6No
Name1RedDCWhiteHigh1/12/2018ProdAQ7NA
Name1RedDCWhiteHigh1/12/2018ProdAQ8No
Name1RedDCWhiteHigh1/12/2018ProdAQ9Yes
Name1RedDCWhiteHigh1/12/2018ProdAQ10No
Name1RedDCWhiteHigh1/12/2018ProdAQ11No
Name1RedDCWhiteHigh12/12/2018ProdAQ12No
Name2BlueDCWhiteHigh12/12/2018ProdAQ1No
Name2BlueDCWhiteHigh12/12/2018ProdAQ2No
Name2BlueDCWhiteHigh12/12/2018ProdAQ3Yes
Name2BlueDCWhiteHigh12/12/2018ProdAQ4No
Name2BlueDCWhiteHigh12/12/2018ProdAQ5No
Name2BlueDCWhiteHigh12/12/2018ProdAQ6No
Name2BlueDCWhiteHigh12/12/2018ProdAQ7Yes
Name2BlueDCWhiteHigh12/12/2018ProdAQ8No
Name2BlueDCWhiteHigh12/12/2018ProdAQ9Yes
Name2BlueDCWhiteHigh12/12/2018ProdAQ10No
Name2BlueDCWhiteHigh12/12/2018ProdAQ11No
Name2BlueDCWhiteHigh12/12/2018ProdAQ12No
Name3GreenAutoWhiteLow4/12/2018ProdBQ1No
Name3GreenAutoWhiteLow4/12/2018ProdBQ2No
Name3GreenAutoWhiteLow4/12/2018ProdBQ3No
Name3GreenAutoWhiteLow4/12/2018ProdBQ4No
Name3GreenAutoWhiteLow4/12/2018ProdBQ5No
Name3GreenAutoWhiteLow4/12/2018ProdBQ6No
Name3GreenAutoWhiteLow4/12/2018ProdBQ7No
Name3GreenAutoWhiteLow4/12/2018ProdBQ8No
Name3GreenAutoWhiteLow4/12/2018ProdBQ9Yes
Name3GreenAutoWhiteLow4/12/2018ProdBQ10Yes
Name3GreenAutoWhiteLow4/12/2018ProdBQ11 No
Name3GreenAutoWhiteLow4/12/2018ProdBQ12NA

<colgroup><col><col><col><col><col span="3"><col span="2"></colgroup><tbody>
</tbody>

Example 2

UniqueIdNameCol3Col4Col5Col6ProdAProdAProdAProdAProdAProdAProdAProdAProdAProdAProdAProdA
Name1RedDCWhiteHigh1/12/2018Q1Q2Q3Q4Q5Q6Q7Q8Q9Q10Q11Q12
Name2BlueDCWhiteHigh12/12/2018YesYesYesNoNoNoNANoYesNoNoNo
Name3GreenAutoWhiteLow4/12/2018NoNoYesNoNoNoYesNoYesNoNoNo

<colgroup><col><col><col><col><col span="3"><col span="4"><col span="5"><col span="2"></colgroup><tbody>
</tbody>

Help appreciated
 
Hello there. Thank you very much for this. Based on the M-code above I have adapted to include more columns however, I receive the following;

Expression.Error: We cannot convert a value of type Table to type List.
Details:
Value=Table
Type=Type

The code is as follows;

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueID", type text}, {" Name", type text}, {" Other Name", type text}, {"Reason", type text}, {"Int Date", type date}, {"Access", type text}, {"Interaction Type", type text}, {"Disc ?", type text}, {"Action required", type text}, {"Est Date", type date}, {"Completed", type date}, {"Contact", type text}, {"New Question ", type text}, {"Product", type text}, {"Answer", type text}}), #"Merged Columns" = Table.CombineColumns(#"Changed Type",{"New Question ", "Product"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"), #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns", {"Merged"}), "Merged", "Answer") in #"Pivoted Column"
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
first TRIM spaces from headers
next try this:
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueId", type text}, {"Name", type text}, {"Other Name", type text}, {"Reason", type text}, {"Int Date", type date}, {"Access", type text}, {"Interaction Type", type text}, {"Disc ?", type text}, {"Action required", type text}, {"Est Date", type date}, {"Completed", type date}, {"Contact", type text}, {"New Question", type text}, {"Product", type text}, {"Answer", type text}}),
    #"Merged Columns" = Table.CombineColumns(#"Changed Type",{"New Question", "Product"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Answer")

in
    #"Pivoted Column"[/SIZE]

your problem is here
your code: #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns", {"Merged"}), "Merged", "Answer")
my code: #"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Answer")

if you post any code use [CODE]your code here[/CODE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,884
Messages
6,122,082
Members
449,064
Latest member
MattDRT

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