Data to change from Columns to Rowns

maheshrk81

Board Regular
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
 

alansidman

Well-known Member
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"
 

sandy666

Well-known Member
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:

Some videos you may like

This Week's Hot Topics

  • Get External Data (long shot question!)
    This is likely a long shot but I am wondering if it is at all possible for Excel to somehow 'change' the contents of a URL that is being linked to...
  • Importing multiple excel files into one spreadsheet
    Hi, I'm trying to import multiple excel files (with the same format into a single spreadsheet) so that each day's file is listed underneath the...
  • Cell Formatting
    Good Morning, I need to format a few different cells in the following manners: A1 has to always add a colon (:) after whatever is typed in by a...
  • How to copy multiple rows using If
    Hi all, I'm very new to VBA and have written this simple code to copy certain cells if a certain cell within that row contains any data. I need...
  • Workbook_Change stopped working !
    I am working on an app to speed up & automate processing of Credit Cards statements. After data is input from a CSV file, it is presented to the...
  • VBA If statement
    Dear All, I have two dates, where I'd like a message box to pop, if the dates are between this criteria. [CODE] sDate1 = #10/1/2019#...
Top