transform table from 2 sheets / Unpivot

viresh23

New Member
Joined
Jul 7, 2016
Messages
2
Opportunity ID

<tbody>
</tbody>
Account Name

<tbody>
</tbody>
Opportunity Name

<tbody>
</tbody>
America User1

<tbody>
</tbody>
America User1 %

<tbody>
</tbody>
Europe User1

<tbody>
</tbody>
Europe User1 %

<tbody>
</tbody>
India User 1

<tbody>
</tbody>
India User 1%

<tbody>
</tbody>
1396865

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
a20b40c40
1458125

<tbody>
</tbody>
Vocable Pte. Ltd.

<tbody>
</tbody>
MACD - CDN for streaming

<tbody>
</tbody>
s80y20
1470989

<tbody>
</tbody>
Testtest accountg100

<tbody>
</tbody>









Input1

Input2
Opportunity ID

<tbody>
</tbody>
Account Name

<tbody>
</tbody>
Opportunity Name

<tbody>
</tbody>
Opportunity Owner

<tbody>
</tbody>
Amount
1396865

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
Malargal Systemssam buttler80000
1458125Vocable Pte. Ltd.MACD - CDN for streamingHari sadu80000
1470989Testtest accountradhika60000

<tbody>
</tbody>










Output
Opportunity ID

<tbody>
</tbody>
Account Name

<tbody>
</tbody>
Opportunity Name

<tbody>
</tbody>
Opportunity Owner

<tbody>
</tbody>
User Name

<tbody>
</tbody>
Sharing %

<tbody>
</tbody>
Amount

<tbody>
</tbody>
1396865

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
sam buttlera2016000
1396865

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
Malargal Systemssam buttlerb4032000
1396865

<tbody>
</tbody>
Malargal Systems

<tbody>
</tbody>
Malargal Systemssam buttlerc4032000
1458125Vocable Pte. Ltd.MACD - CDN for streamingHari sadus8064000
1458125Vocable Pte. Ltd.MACD - CDN for streamingHari saduy2016000

<tbody>
</tbody>

















Hi team,

Here is some challenge. I tried using unpivot.

we require desired output as above output table from Input1 and input2 table. output table is combination of Input1 and input2 table against 'Opportunity id" as Unique filed.

Thanks in advance.

-Viresh
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi Viresh,
I'd recommend using Power Query.
Here is what I easily got, then click on refresh all to update:
OqpN7U.jpg

Code (produced with only clicking on buttons):
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Opportunity ID", Int64.Type}, {"Account Name", type text}, {"Opportunity Name", type text}, {"Opportunity Owner", type text}, {"Amount", Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type",{"Opportunity ID"},Table1,{"Opportunity ID"},"NewColumn",JoinKind.LeftOuter),
    #"Expanded NewColumn" = Table.ExpandTableColumn(#"Merged Queries", "NewColumn", {"America User1", "America User1 %", "Europe User1", "Europe User1 %", "India User 1", "India User 1%"}, {"America User1", "America User1 %", "Europe User1", "Europe User1 %", "India User 1", "India User 1%"}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Expanded NewColumn"),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Demoted Headers", {{"Column7", type text}}, "en-US"),{"Column6", "Column7"},Combiner.CombineTextByDelimiter(";", QuoteStyle.None),"am"),
    #"Merged Columns1" = Table.CombineColumns(Table.TransformColumnTypes(#"Merged Columns", {{"Column9", type text}}, "en-US"),{"Column8", "Column9"},Combiner.CombineTextByDelimiter(";", QuoteStyle.None),"eu"),
    #"Merged Columns2" = Table.CombineColumns(Table.TransformColumnTypes(#"Merged Columns1", {{"Column11", type text}}, "en-US"),{"Column10", "Column11"},Combiner.CombineTextByDelimiter(";", QuoteStyle.None),"eu.1"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Merged Columns2"),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Amount", "Opportunity Owner", "Opportunity Name", "Account Name", "Opportunity ID"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns","Attribute",Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv),{"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Changed Type1","Value",Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv),{"Value.1", "Value.2"}),
    #"Changed Type2" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Value.1", type text}, {"Value.2", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type2",{{"Value.1", "User Name"}, {"Value.2", "Sharing %"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "Amount.1", each [Amount]*[#"Sharing %"]/100),
    #"Renamed Columns1" = Table.RenameColumns(#"Added Custom",{{"Amount", "Amount Total"}, {"Amount.1", "Amount"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns1", each ([User Name] <> "")),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Attribute.2"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Removed Columns","Attribute.1",Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false),{"Attribute.1.1", "Attribute.1.2"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Split Column by Delimiter2",{"Attribute.1.2", "Amount Total"}),
    #"Renamed Columns2" = Table.RenameColumns(#"Removed Columns1",{{"Attribute.1.1", "Country"}})
in
    #"Renamed Columns2"

Do some research online if you're interested.
Olivier.
 
Upvote 0
viresh23,

Welcome to the MrExcel forum.

Thanks for the Private Message.

I have no experience with Pivot Tables.

It looks like olivierhbh may have a solution for you.
 
Upvote 0

Forum statistics

Threads
1,215,758
Messages
6,126,718
Members
449,332
Latest member
nokoloina

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