Power Query: Creating ordered table from multiple columns based on left column

Viau1337

New Member
Joined
Jul 26, 2022
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hello! I have just discovered power query for something I am doing and have been trying to set something of this sort:

I have a query with two columns, one of them is called Topic, the other Sub Topic
Topics each have a couple of sub topics within them

1660753927025.png

I'm trying to convert it with a power query to a table that will sort them a bit like so:

1660753966577.png


Anyway I can get some help on this?
I'm using power query because there may be new topics and sub topics added eventually and want them to automatically update due to multiple formulas that are based on this table.

Thanks!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    tbl = Table.Group(Source, {"Topic"}, {{"All", each List.Sort([Sub Topic])}}),
    tbl1 = Table.Sort(tbl,{{"Topic", Order.Ascending}}),
    Result = Table.FromColumns(tbl1[All], tbl1[Topic])
in
    Result

Book1
ABCDEFG
1TopicSub TopicABC
2B9124
3B6735
4A1111612
5B38
6C129
7B1010
8A1
9C4
10C5
11B8
12A7
13B2
14
Sheet2
 
Upvote 0
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    tbl = Table.Group(Source, {"Topic"}, {{"All", each List.Sort([Sub Topic])}}),
    tbl1 = Table.Sort(tbl,{{"Topic", Order.Ascending}}),
    Result = Table.FromColumns(tbl1[All], tbl1[Topic])
in
    Result

Book1
ABCDEFG
1TopicSub TopicABC
2B9124
3B6735
4A1111612
5B38
6C129
7B1010
8A1
9C4
10C5
11B8
12A7
13B2
14
Sheet2
OMG Thank you so much!! I had went and created a bunch of connections just to arrive to that result, that makes it much easier!
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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