Data to change from Columns to Rowns

maheshrk81

Board Regular
Joined
Jan 5, 2010
Messages
153
Hi All,

I have a data as below. Now I need the same with Cust ID, Cust Name and 3rd Column as Fiscal Month and get the Month column to Rows and 4th Column as Amount and get those in rows respectively. Can someone help

[TABLE="width: 500"]
<tbody>[TR]
[TD]Cust ID [/TD]
[TD]Cust Name<strike></strike>
[/TD]
[TD][FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Jul[/FONT]<strike></strike>
[/TD]
[TD]Aug<strike></strike>
[/TD]
[TD]Sep[/TD]
[TD]Oct[/TD]
[TD]Nov[/TD]
[TD]Dec[/TD]
[TD]Jan[/TD]
[TD]Feb[/TD]
[TD]Mar[/TD]
[TD]Apr[/TD]
[TD]May[/TD]
[TD]Jun[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]124[/TD]
[TD]abc[/TD]
[TD]654654[/TD]
[TD]566[/TD]
[TD]155[/TD]
[TD]6496[/TD]
[TD]65467[/TD]
[TD]686[/TD]
[TD]886[/TD]
[TD]9963[/TD]
[TD]966[/TD]
[TD]9863[/TD]
[TD]35[/TD]
[TD]668[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]416546[/TD]
[TD]wer[/TD]
[TD]48[/TD]
[TD]56698[/TD]
[TD]656[/TD]
[TD]6633[/TD]
[TD]666[/TD]
[TD]6623[/TD]
[TD]335[/TD]
[TD]333[/TD]
[TD][/TD]
[TD]8[/TD]
[TD]66[/TD]
[TD]77[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]665265[/TD]
[TD]thj[/TD]
[TD]6864[/TD]
[TD]6289[/TD]
[TD]66[/TD]
[TD]566[/TD]
[TD]6645[/TD]
[TD]582[/TD]
[TD]33[/TD]
[TD]6366[/TD]
[TD]65[/TD]
[TD]366[/TD]
[TD]98[/TD]
[TD]546[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]65654[/TD]
[TD]yui[/TD]
[TD][/TD]
[TD]967[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9852[/TD]
[TD]opz[/TD]
[TD]646[/TD]
[TD]339[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6823[/TD]
[TD]tre[/TD]
[TD]649[/TD]
[TD]33694[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]57[/TD]
[TD]xyz[/TD]
[TD]888[/TD]
[TD]669[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]783[/TD]
[TD]pqr[/TD]
[TD]698[/TD]
[TD]3969[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks,
Mahi
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Data Range
[Table="class: grid"][tr][td] [/td][td]
A
[/td][td]
B
[/td][td]
C
[/td][td]
D
[/td][/tr]
[tr][td]
1
[/td][td]
Cust ID​
[/td][td]
Attribute​
[/td][td]
Value​
[/td][td]
Custom​
[/td][/tr]


[tr][td]
2
[/td][td]
124​
[/td][td]
Jul​
[/td][td]
654654​
[/td][td]
abc​
[/td][/tr]


[tr][td]
3
[/td][td]
124​
[/td][td]
Aug​
[/td][td]
566​
[/td][td]
abc​
[/td][/tr]


[tr][td]
4
[/td][td]
124​
[/td][td]
Sep​
[/td][td]
155​
[/td][td]
abc​
[/td][/tr]


[tr][td]
5
[/td][td]
124​
[/td][td]
Oct​
[/td][td]
6496​
[/td][td]
abc​
[/td][/tr]


[tr][td]
6
[/td][td]
124​
[/td][td]
Nov​
[/td][td]
65467​
[/td][td]
abc​
[/td][/tr]


[tr][td]
7
[/td][td]
124​
[/td][td]
Dec​
[/td][td]
686​
[/td][td]
abc​
[/td][/tr]


[tr][td]
8
[/td][td]
124​
[/td][td]
Jan​
[/td][td]
886​
[/td][td]
abc​
[/td][/tr]


[tr][td]
9
[/td][td]
124​
[/td][td]
Feb​
[/td][td]
9963​
[/td][td]
abc​
[/td][/tr]


[tr][td]
10
[/td][td]
124​
[/td][td]
Mar​
[/td][td]
966​
[/td][td]
abc​
[/td][/tr]


[tr][td]
11
[/td][td]
124​
[/td][td]
Apr​
[/td][td]
9863​
[/td][td]
abc​
[/td][/tr]


[tr][td]
12
[/td][td]
124​
[/td][td]
May​
[/td][td]
35​
[/td][td]
abc​
[/td][/tr]


[tr][td]
13
[/td][td]
124​
[/td][td]
Jun​
[/td][td]
668​
[/td][td]
abc​
[/td][/tr]


[tr][td]
14
[/td][td]
416546​
[/td][td]
Jul​
[/td][td]
48​
[/td][td]
wer​
[/td][/tr]


[tr][td]
15
[/td][td]
416546​
[/td][td]
Aug​
[/td][td]
56698​
[/td][td]
wer​
[/td][/tr]


[tr][td]
16
[/td][td]
416546​
[/td][td]
Sep​
[/td][td]
656​
[/td][td]
wer​
[/td][/tr]


[tr][td]
17
[/td][td]
416546​
[/td][td]
Oct​
[/td][td]
6633​
[/td][td]
wer​
[/td][/tr]


[tr][td]
18
[/td][td]
416546​
[/td][td]
Nov​
[/td][td]
666​
[/td][td]
wer​
[/td][/tr]


[tr][td]
19
[/td][td]
416546​
[/td][td]
Dec​
[/td][td]
6623​
[/td][td]
wer​
[/td][/tr]


[tr][td]
20
[/td][td]
416546​
[/td][td]
Jan​
[/td][td]
335​
[/td][td]
wer​
[/td][/tr]


[tr][td]
21
[/td][td]
416546​
[/td][td]
Feb​
[/td][td]
333​
[/td][td]
wer​
[/td][/tr]


[tr][td]
22
[/td][td]
416546​
[/td][td]
Apr​
[/td][td]
8​
[/td][td]
wer​
[/td][/tr]


[tr][td]
23
[/td][td]
416546​
[/td][td]
May​
[/td][td]
66​
[/td][td]
wer​
[/td][/tr]


[tr][td]
24
[/td][td]
416546​
[/td][td]
Jun​
[/td][td]
77​
[/td][td]
wer​
[/td][/tr]


[tr][td]
25
[/td][td]
665265​
[/td][td]
Jul​
[/td][td]
6864​
[/td][td]
thj​
[/td][/tr]


[tr][td]
26
[/td][td]
665265​
[/td][td]
Aug​
[/td][td]
6289​
[/td][td]
thj​
[/td][/tr]


[tr][td]
27
[/td][td]
665265​
[/td][td]
Sep​
[/td][td]
66​
[/td][td]
thj​
[/td][/tr]


[tr][td]
28
[/td][td]
665265​
[/td][td]
Oct​
[/td][td]
566​
[/td][td]
thj​
[/td][/tr]


[tr][td]
29
[/td][td]
665265​
[/td][td]
Nov​
[/td][td]
6645​
[/td][td]
thj​
[/td][/tr]


[tr][td]
30
[/td][td]
665265​
[/td][td]
Dec​
[/td][td]
582​
[/td][td]
thj​
[/td][/tr]


[tr][td]
31
[/td][td]
665265​
[/td][td]
Jan​
[/td][td]
33​
[/td][td]
thj​
[/td][/tr]


[tr][td]
32
[/td][td]
665265​
[/td][td]
Feb​
[/td][td]
6366​
[/td][td]
thj​
[/td][/tr]


[tr][td]
33
[/td][td]
665265​
[/td][td]
Mar​
[/td][td]
65​
[/td][td]
thj​
[/td][/tr]


[tr][td]
34
[/td][td]
665265​
[/td][td]
Apr​
[/td][td]
366​
[/td][td]
thj​
[/td][/tr]


[tr][td]
35
[/td][td]
665265​
[/td][td]
May​
[/td][td]
98​
[/td][td]
thj​
[/td][/tr]


[tr][td]
36
[/td][td]
665265​
[/td][td]
Jun​
[/td][td]
546​
[/td][td]
thj​
[/td][/tr]


[tr][td]
37
[/td][td]
65654​
[/td][td]
Aug​
[/td][td]
967​
[/td][td]
yui​
[/td][/tr]


[tr][td]
38
[/td][td]
9852​
[/td][td]
Jul​
[/td][td]
646​
[/td][td]
opz​
[/td][/tr]


[tr][td]
39
[/td][td]
9852​
[/td][td]
Aug​
[/td][td]
339​
[/td][td]
opz​
[/td][/tr]


[tr][td]
40
[/td][td]
6823​
[/td][td]
Jul​
[/td][td]
649​
[/td][td]
tre​
[/td][/tr]


[tr][td]
41
[/td][td]
6823​
[/td][td]
Aug​
[/td][td]
33694​
[/td][td]
tre​
[/td][/tr]


[tr][td]
42
[/td][td]
57​
[/td][td]
Jul​
[/td][td]
888​
[/td][td]
xyz​
[/td][/tr]


[tr][td]
43
[/td][td]
57​
[/td][td]
Aug​
[/td][td]
669​
[/td][td]
xyz​
[/td][/tr]


[tr][td]
44
[/td][td]
783​
[/td][td]
Jul​
[/td][td]
698​
[/td][td]
pqr​
[/td][/tr]


[tr][td]
45
[/td][td]
783​
[/td][td]
Aug​
[/td][td]
3969​
[/td][td]
pqr​
[/td][/tr]
[/table]
Using Power Query, here is the Mcode

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cust ID", Int64.Type}, {"Cust Name", type text}, {"Jul", Int64.Type}, {"Aug", Int64.Type}, {"Sep", Int64.Type}, {"Oct", Int64.Type}, {"Nov", Int64.Type}, {"Dec", Int64.Type}, {"Jan", Int64.Type}, {"Feb", Int64.Type}, {"Mar", Int64.Type}, {"Apr", Int64.Type}, {"May", Int64.Type}, {"Jun", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Cust ID"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Other Columns", "Custom", each if [Attribute] = "Cust Name" then [Value] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Attribute] <> "Cust Name"))
in
    #"Filtered Rows"
 
Upvote 0
shorter:

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UnpivotOC = Table.UnpivotOtherColumns(Source, {"Cust ID", "Cust Name"}, "Month", "Value")
in
    UnpivotOC[/SIZE]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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