Power Query : Transpose Column To Rows Then Fill Down Date in Other Column

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,102
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all..

i need formula into power query, how to transpose data column into data rows with criteria:
1. each region and other columns repeat 12 times (always) then
2. data column 'sold jan 22 till dec 22', transpose to rows;
3. add the custom column and fill down with date format (dd/mm/yyyy) from month Jan till Dec 22
here that layout table
tranpose complex.xlsx
ABCDEFGHIJKLMNO
1original data set
2RegionTargetActualsold 'Jan 22sold Feb 22sold 'Mar 22sold 'Apr 22sold 'Mei 22sold 'Jun 22sold 'Jul 22sold 'Agust 22sold 'Sept 22sold 'Okt22sold 'Nov 22sold 'Des22
3A654010567689063412
4B60202045657689999
5C5030301010101010101212121212
6D5523231516202020202020202020
7E6525251630303030303030303030
8F7035301745454545454545454545
9G62602121506565465565656565
10
11after using formula in PQ
12RegionTargetActualsold outcustom col. (as data format)- expected result
13A65401001/01/2022
14A6540501/02/2022
15A6540601/03/2022
16A6540701/04/2022
17A6540601/05/2022
18A6540801/06/2022
19A6540901/07/2022
20A6540001/08/2022
21A6540601/09/2022
22A6540301/10/2022
23A6540401/11/2022
24A60401201/12/2022
25B6020401/01/2022
26B6020501/02/2022
27B6020601/03/2022
28B6020501/04/2022
29B6020701/05/2022
30B6020601/06/2022
31B6020801/07/2022
32B6020901/08/2022
33B6020901/09/2022
34B6020901/10/2022
35B6020901/11/2022
36B6020901/12/2022
37C
38C
39etc,,
Sheet1


anyone help, greatly appreciated

susant
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
In Power Query, choose all the sold [month] columns at once, then go to the Transform tab and select unPivot Columns. Here's the result for region A.

1666458324631.png


The do another table which associates "sold 'Jan 22" with 01/01/2022, and merge the two queries.
 
Upvote 0
hi Automatrix, thank you so much...
please, how to add column date? in my sample in col E13 down..
sorry'i'm new bie about PQ.
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Region", "Target", "Actual"}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Other Columns","sold"," ",Replacer.ReplaceText,{"Attribute"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","'"," ",Replacer.ReplaceText,{"Attribute"}),
    #"Trimmed Text" = Table.TransformColumns(#"Replaced Value1",{{"Attribute", Text.Trim, type text}})
in
    #"Trimmed Text"

If you wish to continue to play in PQ, then I suggest you pick up this book by Ken Puls and Miguel Escobar Master Your Data with Power Query in Excel and Power BI
 
Upvote 0
Solution

Forum statistics

Threads
1,224,814
Messages
6,181,121
Members
453,021
Latest member
Justyna P

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