Transpose Data to Create new table

zifu886

New Member
Joined
Jul 10, 2019
Messages
13
Hi Expert,

Im learning excel while I work on parsing large amount data. Need your help me to create a new table from old table as listed below. Your help is highly appreciated. Thank you once again in advance for your great help,

Sincerely
Zi

Source Table
Order_AgingCompanyOrder DateOrderOrder Due DateAmount
1 - 30All-Good12/11/2018123412/11/20182400
31 - 60All-Good11/26/2018120011/26/20187200
CurrentUC-Tower12/21/2018 #4012/31/20181100
1 - 30UC-Tower12/7/2018135200
- 90UC-Tower12/7/2018#3812/17/2018100
> 90UC-Tower12/21/201813615000
currentHello.com12/17/2018 #76571/16/201990
currentHello.com12/31/2018721/10/2019100
New Table
Order_AgingCompanyOrder DateOrderOrder Due DateCurrent1 - 3031 - 6061 - 90> 90Amount
1 - 30All-Good12/11/2018123412/11/201824002400
31 - 60All-Good11/26/2018120011/26/201824002400
currentUC-Tower12/21/2018 #4012/31/201811001100
1 - 30UC-Tower12/7/2018135200200
61 - 90UC-Tower12/7/2018#3812/17/2018100100
> 90UC-Tower12/21/20181361500015000
currentHello.com12/17/2018 #76571/16/20199090
currentHello.com12/31/2018721/10/2019100100

<tbody>
</tbody>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I doubt I'll answer this as I'm busy at work but

in the New Table

why does 2400 appear in the 31-60 column for All-Good 11/26/2018 ?
The value is 7200 which doesn't appear ANYWHERE in the New Table
 
Last edited:
Upvote 0
with PowerQuery (Get&Transform)

sourceresult
Order_AgingCompanyOrder DateOrderOrder Due DateAmountOrder_AgingCompanyOrder DateOrderOrder Due Datecurrent1 - 3031 - 60-90> 90Amount
1 - 30All-Good
11/12/2018​
1234​
11/12/2018​
2400​
1 - 30All-Good
11/12/2018​
1234
11/12/2018​
2400​
2400​
31 - 60All-Good
26/11/2018​
1200​
26/11/2018​
7200​
31 - 60All-Good
26/11/2018​
1200
26/11/2018​
7200​
7200​
currentUC-Tower
21/12/2018​
#40
31/12/2018​
1100​
currentUC-Tower
21/12/2018​
#40
31/12/2018​
1100​
1100​
1 - 30UC-Tower
07/12/2018​
135​
200​
1 - 30UC-Tower
07/12/2018​
135
200​
200​
-90​
UC-Tower
07/12/2018​
#38
17/12/2018​
100​
-90UC-Tower
07/12/2018​
#38
17/12/2018​
100​
100​
> 90UC-Tower
21/12/2018​
136​
15000​
> 90UC-Tower
21/12/2018​
136
15000​
15000​
currentHello.com
17/12/2018​
#7657
16/01/2019​
90​
currentHello.com
17/12/2018​
#7657
16/01/2019​
90​
90​
currentHello.com
31/12/2018​
72​
10/01/2019​
100​
currentHello.com
31/12/2018​
72
10/01/2019​
100​
100​

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Order_Aging", type text}, {"Company", type text}, {"Order Date", type date}, {"Order", type text}, {"Order Due Date", type date}, {"Amount", Int64.Type}}),
    Index = Table.AddIndexColumn(Type, "Index", 0, 1),
    Duplicta1 = Table.DuplicateColumn(Index, "Order_Aging", "Order_Aging - Copy"),
    Duplicate2 = Table.DuplicateColumn(Duplicta1, "Amount", "Amount - Copy"),
    Pivot = Table.Pivot(Duplicate2, List.Distinct(Duplicate2[#"Order_Aging - Copy"]), "Order_Aging - Copy", "Amount - Copy", List.Sum),
    Sort = Table.Sort(Pivot,{{"Index", Order.Ascending}}),
    RC = Table.RemoveColumns(Sort,{"Index"}),
    REorder = Table.ReorderColumns(RC,{"Order_Aging", "Company", "Order Date", "Order", "Order Due Date", "current", "1 - 30", "31 - 60", "-90", "> 90", "Amount"})
in
    REorder[/SIZE]
 
Upvote 0
Hi Special-K99,
good afternoon, Thanks much for your reply. That is a typo when I transferred the data. the All-Good 11/26/2018 for 31-60 should be "7200" and amount should be updated to 7200 as well. What I tried to achieve is to convert the source table to a new table by inserting the new Column(s) and each column's title = the unique value from Column A, then copy the amount.value to the corresponded new Column (eg, A2="1-30", then copy amount.value (row#2) ) to the new Column (1-30) being created), so on and so forth. Does this make sense? Thank you very much for your help,

Sincerely
Zi
 
Upvote 0
Hi Sandy666,

good morning, Thank you very much for your the M-codes. I used 2013 excel & honestly, I am not familiar with the power query, but tried to download pwoerquery onto excel, and did quick learning to run the power but when I run the M-code, I keep getting below errors, could you please provide me some guidances to run the run. I appreciate your time & help, thank you once again,

Sincerely
Zi

-------------------------------------------------------------------------
Expression.Error: We couldn't find an Excel table named 'Table1'.
Details:
Table1

-------------------------------------------------------------------------
 
Upvote 0
because your source range must be a table, Excel Table ! (see source in my post)
Use Ctrl+T then check in name manager the name of this table and change the name in the code if neccesary
 
Last edited:
Upvote 0
Hi Sandy666,

Great, I was able to run M-Code with Power Query and result is just perfect that I am looking for it, Pwer Query is powerful but I am totally just a beginner & need deeping more about it. Do you know how to use a macro to achieve the same results. Much Appreciate & thank you once again for your great help,

Sincerely
Zi
 
Upvote 0
Zi,
A really good starting point for PQ is Ken Puls book "M is for (Data) Monkey"
 
Upvote 0
Hi Alan

thanks much for your info. I found it from Amazon & ordered one. thanks again for your info,

Have a nice weekend,

Sincerely
Zi
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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