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

Cust ID Cust Name<strike></strike>
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Jul[/FONT]<strike></strike>
Aug<strike></strike>
SepOctNovDecJanFebMarAprMayJun
124abc6546545661556496654676868869963966986335668
416546wer48566986566633666662333533386677
665265thj686462896656666455823363666536698546
65654yui967
9852opz646339
6823tre64933694
57xyz888669
783pqr6983969

<tbody>
</tbody>

Thanks,
Mahi
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Data Range
A
B
C
D
1
Cust ID​
Attribute​
Value​
Custom​
2
124​
Jul​
654654​
abc​
3
124​
Aug​
566​
abc​
4
124​
Sep​
155​
abc​
5
124​
Oct​
6496​
abc​
6
124​
Nov​
65467​
abc​
7
124​
Dec​
686​
abc​
8
124​
Jan​
886​
abc​
9
124​
Feb​
9963​
abc​
10
124​
Mar​
966​
abc​
11
124​
Apr​
9863​
abc​
12
124​
May​
35​
abc​
13
124​
Jun​
668​
abc​
14
416546​
Jul​
48​
wer​
15
416546​
Aug​
56698​
wer​
16
416546​
Sep​
656​
wer​
17
416546​
Oct​
6633​
wer​
18
416546​
Nov​
666​
wer​
19
416546​
Dec​
6623​
wer​
20
416546​
Jan​
335​
wer​
21
416546​
Feb​
333​
wer​
22
416546​
Apr​
8​
wer​
23
416546​
May​
66​
wer​
24
416546​
Jun​
77​
wer​
25
665265​
Jul​
6864​
thj​
26
665265​
Aug​
6289​
thj​
27
665265​
Sep​
66​
thj​
28
665265​
Oct​
566​
thj​
29
665265​
Nov​
6645​
thj​
30
665265​
Dec​
582​
thj​
31
665265​
Jan​
33​
thj​
32
665265​
Feb​
6366​
thj​
33
665265​
Mar​
65​
thj​
34
665265​
Apr​
366​
thj​
35
665265​
May​
98​
thj​
36
665265​
Jun​
546​
thj​
37
65654​
Aug​
967​
yui​
38
9852​
Jul​
646​
opz​
39
9852​
Aug​
339​
opz​
40
6823​
Jul​
649​
tre​
41
6823​
Aug​
33694​
tre​
42
57​
Jul​
888​
xyz​
43
57​
Aug​
669​
xyz​
44
783​
Jul​
698​
pqr​
45
783​
Aug​
3969​
pqr​
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,213,494
Messages
6,113,986
Members
448,538
Latest member
alex78

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