Transpose Large Data Help

devint

New Member
Joined
Dec 17, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Morning,

Hoping someone might have knowledge that may help me. I have to run a data pull every month. It comes in a certain format, and I need to transpose it into another format. I understand the transpose part, but only for a single set of data. My data is about 6000 rows long.

This is the format the data comes in:

G80012
ASHGREY
S​
M​
L​
XL​
2XL​
3XL​
4XL​
5XL​
RegularPrice
$2.24​
$2.24​
$2.24​
$2.24​
$4.43​
$6.03​
$5.98​
$5.99​
SpecialPrice
$1.92​
$1.92​
$1.92​
$1.92​
Total-Inventory
27322​
4868​
16127​
2190​
78​
0​
10​
11​
AZALEA
S​
M​
L​
XL​
2XL​
3XL​
4XL​
5XL​
RegularPrice
$2.32​
$2.32​
$2.32​
$2.32​
$4.91​
$6.34​
$6.28​
$6.28​
SpecialPrice
$2.03​
$2.03​
$2.03​
$2.03​
Total-Inventory
1646​
2000​
1355​
436​
427​
70​
0​
0​
BLACK
S​
M​
L​
XL​
2XL​
3XL​
4XL​
5XL​
RegularPrice
$2.32​
$2.32​
$2.32​
$2.32​
$4.91​
$6.34​
$6.28​
$6.28​
SpecialPrice
$2.03​
$2.03​
$2.03​
$2.03​
Total-Inventory
35935​
56924​
67178​
28203​
10723​
5075​
144​
1006​

My ideal end result would look like this:

Style​
Color​
Size​
RegularPrice​
SpecialPrice​
Total-Inventory​
G80012​
ASHGREY​
S​
$2.24​
$1.92​
27322​
G80012​
ASHGREY​
M​
$2.24​
$1.92​
4868​
G80012​
ASHGREY​
L​
$2.24​
$1.92​
16127​
G80012​
ASHGREY​
XL​
$2.24​
$1.92​
2190​
G80012​
ASHGREY​
2XL​
$4.43​
78​
G80012​
ASHGREY​
3XL​
$6.03​
0​
G80012​
ASHGREY​
4XL​
$5.98​
10​
G80012​
ASHGREY​
5XL​
$5.99​
11​
G80012​
AZALEA​
S​
$2.32​
$2.03​
1646​
G80012​
AZALEA​
M​
$2.32​
$2.03​
2000​
G80012​
AZALEA​
L​
$2.32​
$2.03​
1355​
G80012​
AZALEA​
XL​
$2.32​
$2.03​
436​
G80012​
AZALEA​
2XL​
$4.91​
427​
G80012​
AZALEA​
3XL​
$6.34​
70​
G80012​
AZALEA​
4XL​
$6.28​
0​
G80012​
AZALEA​
5XL​
$6.28​
0​
G80012​
BLACK​
S​
$2.32​
$2.03​
35935​
G80012​
BLACK​
M​
$2.32​
$2.03​
56924​
G80012​
BLACK​
L​
$2.32​
$2.03​
67178​
G80012​
BLACK​
XL​
$2.32​
$2.03​
28203​
G80012​
BLACK​
2XL​
$4.91​
10723​
G80012​
BLACK​
3XL​
$6.34​
5075​
G80012​
BLACK​
4XL​
$6.28​
144​
G80012​
BLACK​
5XL​
$6.28​
1006​

I can do a transpose and manually copy/paste each 'color', but with 150 colors this would take me a long time. Was hoping there was a formula or macro that can achieve this with a few strokes.

This is beyond my knowledge of excel, so hoping I can find help here.

Thanks,
 
You are amazing man. Appreciate all your help, this saved me hours of work a month.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Sorry to be late to the party, but here is a Power Query Solution.

Book3
ABCDEF
1ColorStyleSizeRegularPriceSpecialPriceTotal-Inventory
2ASHGREYG801S2.241.9227322
3ASHGREYG802M2.241.924868
4ASHGREYG803L2.241.9216127
5ASHGREYG804XL2.241.922190
6ASHGREYG8052XL4.4378
7ASHGREYG8063XL6.030
8ASHGREYG8074XL5.9810
9ASHGREYG8085XL5.9911
10AZALEAG801S2.322.031646
11AZALEAG802M2.322.032000
12AZALEAG803L2.322.031355
13AZALEAG804XL2.322.03436
14AZALEAG8052XL4.91427
15AZALEAG8063XL6.3470
16AZALEAG8074XL6.280
17AZALEAG8085XL6.280
18BLACKG801S2.322.0335935
19BLACKG802M2.322.0356924
20BLACKG803L2.322.0367178
21BLACKG804XL2.322.0328203
22BLACKG8052XL4.9110723
23BLACKG8063XL6.345075
24BLACKG8074XL6.28144
25BLACKG8085XL6.281006
26CAROLINABLUEG801S2.322.0327833
27CAROLINABLUEG802M2.322.035947
28CAROLINABLUEG803L2.322.033580
29CAROLINABLUEG804XL2.322.034363
30CAROLINABLUEG8052XL4.914179
31CAROLINABLUEG8063XL6.34556
32CAROLINABLUEG8074XL6.280
33CAROLINABLUEG8085XL6.280
34DAISYG801S2.3227886
35DAISYG802M2.3210266
36DAISYG803L2.324470
37DAISYG804XL2.329997
38DAISYG8052XL4.911126
39DAISYG8063XL6.342584
40DAISYG8074XL6.289
41DAISYG8085XL6.280
42DARKCHOCOLATEG801S2.562.030
43DARKCHOCOLATEG802M2.560.750
44DARKCHOCOLATEG803L2.562.0351
45DARKCHOCOLATEG804XL2.562.030
46DARKCHOCOLATEG8052XL4.460
47DARKCHOCOLATEG8063XL5.990
48DARKCHOCOLATEG8074XL5.990
49DARKCHOCOLATEG8085XL5.990
50DARKHEATHERG801S2.322.0322425
51DARKHEATHERG802M2.322.039243
52DARKHEATHERG803L2.322.0313362
53DARKHEATHERG804XL2.322.033286
54DARKHEATHERG8052XL4.912633
55DARKHEATHERG8063XL6.340
56DARKHEATHERG8074XL6.280
57DARKHEATHERG8085XL6.2831
58ELECTRICGREENG801S2.322.0320806
59ELECTRICGREENG802M2.322.0321523
60ELECTRICGREENG803L2.322.0319842
61ELECTRICGREENG804XL2.322.0312098
62ELECTRICGREENG8052XL4.913409
63ELECTRICGREENG8063XL6.34796
64ELECTRICGREENG8074XL6.28313
65ELECTRICGREENG8085XL6.280
Table1 (2)


Mcode:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"G800", type text}, {"G801", type any}, {"G802", type any}, {"G803", type any}, {"G804", type any}, {"G805", type any}, {"G806", type any}, {"G807", type any}, {"G808", type any}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if[G801]= "S" then[G800] else null),
    #"Demoted Headers" = Table.DemoteHeaders(#"Added Custom"),
    #"Transposed Table" = Table.Transpose(#"Demoted Headers"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Merged Columns" = Table.CombineColumns(#"Promoted Headers",{"G800", "ASHGREY"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Merged"),
    #"Demoted Headers1" = Table.DemoteHeaders(#"Merged Columns"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Demoted Headers1",{{"Column1", type text}, {"Column2", type any}, {"Column3", type any}, {"Column4", type any}, {"Column5", type text}, {"Column6", type any}, {"Column7", type any}, {"Column8", type any}, {"Column9", type text}, {"Column10", type any}, {"Column11", type any}, {"Column12", type any}, {"Column13", type text}, {"Column14", type any}, {"Column15", type any}, {"Column16", type any}, {"Column17", type text}, {"Column18", type any}, {"Column19", type any}, {"Column20", type text}, {"Column21", type any}, {"Column22", type any}, {"Column23", type any}, {"Column24", type text}, {"Column25", type any}, {"Column26", type any}, {"Column27", type any}, {"Column28", type text}, {"Column29", type any}, {"Column30", type any}, {"Column31", type any}}),
    #"Transposed Table1" = Table.Transpose(#"Changed Type2"),
    #"Promoted Headers1" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true]),
    #"Filled Down" = Table.FillDown(#"Promoted Headers1",{"Custom:ASHGREY"}),
    #"Replaced Value" = Table.ReplaceValue(#"Filled Down",null,"ASHGREY",Replacer.ReplaceValue,{"Custom:ASHGREY"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Replaced Value",{"Custom:ASHGREY", "Merged", "G801:S", "G802:M", "G803:L", "G804:XL", "G805:2XL", "G806:3XL", "G807:4XL", "G808:5XL"}),
    #"Filtered Rows" = Table.SelectRows(#"Reordered Columns", each ([#"G801:S"] <> "S")),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Filtered Rows", {"Custom:ASHGREY", "Merged"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Merged"}, {{"Data", each _, type table [#"Custom:ASHGREY"=text, Merged=text, Attribute=text, Value=number]}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Data], "Index", 1, 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Data"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Custom:ASHGREY", "Attribute", "Value", "Index"}, {"Custom:ASHGREY", "Attribute", "Value", "Index"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Custom",{{"Custom:ASHGREY", "Color"}}),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Renamed Columns", "Merged", Splitter.SplitTextByCharacterTransition((c) => not List.Contains({"0".."9"}, c), {"0".."9"}), {"Merged.1", "Merged.2"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Split Column by Character Transition",{"Merged.2"}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Columns1", "Merged.1", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Merged.1.1", "Merged.1.2"}),
    #"Removed Columns2" = Table.RemoveColumns(#"Split Column by Delimiter",{"Merged.1.2"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns2", List.Distinct(#"Removed Columns2"[Merged.1.1]), "Merged.1.1", "Value"),
    #"Removed Columns3" = Table.RemoveColumns(#"Pivoted Column",{"Index"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Removed Columns3", "Attribute", Splitter.SplitTextByDelimiter(":", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Attribute.1", type text}, {"Attribute.2", type text}}),
    #"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Attribute.2", "Size"}, {"Attribute.1", "Style"}})
in
    #"Renamed Columns1"
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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