Power Query : Transpose To Multiple Column Based Criteria

muhammad susanto

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

how to transpose from multiple column to multiple column based on specific criteria or name
here this layout
Book1
ABCDEFGHIJK
1original dataafter using Power Query
2RegionModelDateAmount
3HongkongBMW01/03/202210BMW01/03/202210Mercy01/03/20225
4HongkongBMW01/04/202210BMW01/04/202210Mercy01/04/20225
5HongkongBMW01/05/202210BMW01/05/202210Mercy01/05/20225
6HongkongBMW01/06/202210BMW01/06/202210Mercy01/06/202220
7HongkongBMW01/07/202210BMW01/07/202210Mercy01/07/202220
8HongkongBMW01/08/202210BMW01/08/202210Mercy01/08/202220
9HongkongBMW01/09/202210BMW01/09/202210Mercy01/09/202220
10HongkongBMW01/10/20220BMW01/10/20220Mercy01/10/20220
11HongkongBMW01/11/20220BMW01/11/20220Mercy01/11/20220
12HongkongBMW01/12/20220BMW01/12/20220Mercy01/12/20220
13MalayMercy01/03/20225
14MalayMercy01/04/20225
15MalayMercy01/05/20225
16MalayMercy01/06/202220
17MalayMercy01/07/202220
18MalayMercy01/08/202220
19MalayMercy01/09/202220
20MalayMercy01/10/20220
21MalayMercy01/11/20220
22MalayMercy01/12/20220
Sheet1


i want to transpose based criterai name in col. model (BMW & Mercy)
thank anyone help me out.

susant
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about this?

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Split = Table.Split(Table.SelectColumns(Source,List.Skip(Table.ColumnNames(Source),1)),10),
    ToTables = List.Transform(List.Transform(Split, each Table.ToColumns(_)), each Table.FromRows(_)),
    lstToTable = Table.FromList(ToTables, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Expand = Table.ExpandTableColumn(lstToTable, "Column1", {"Column1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10"}, {"Column1.1", "Column2", "Column3", "Column4", "Column5", "Column6", "Column7", "Column8", "Column9", "Column10"}),
    Transpose = Table.Transpose(Expand)
in
    Transpose
 
Upvote 0
Solution
Found a better way.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Combine = List.Transform(
                Table.Split(
                    Table.SelectColumns(
                        Source,
                        List.Skip(Table.ColumnNames(Source),1)
                    ),
                    let 
                        lst = Source[Model],
                        cnt = List.Count(lst)/List.Count(List.Distinct(lst))
                    in
                        cnt
                ), 
                each Table.ToColumns(_)),
    Expand = Table.FromColumns(List.Accumulate(Combine,{}, (s,c)=> s & c))
in
    Expand
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
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