Power Query - can you use rows as column headers?

leightx

New Member
Joined
Jan 3, 2017
Messages
10
Here's my situation. I want to create a table that uses some of the rows from one column as column headers. I'm not sure if I'm explaining this correctly, so here's an example. And there might be a much easier way to do this - I'm trying to make sure I'm not putting data into several different places, and that everything is connected.

I have a table with items in several levels of categories. I want to use items that are catB as column headers in a power query (if possible) - the items in the other categories (all but catB) will

ItemCategory1Category2
Item1catA
Item2catB
Item3catA
Item4catB
Item5catC
Item6catB

<tbody>
</tbody>

What I need is to:
1) Add more column headers as I add catB rows to the 1st table.
2) I do NOT want to pull any other values from the 1st table over. This is new table and I need to make selections at this point.

ItemDescItem2Item4Item6
Item1
Item3
Item5

<tbody>
</tbody>

Maybe a power query isn't the right tool for this job? I just need something that is dynamic, and adds column headers to the 2nd table as I add catB rows to the first.

Help please!?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
It will take some additional steps, but you will head to the UnPivot tool in PowerQuery.
 
Upvote 0
My suggestion is to make use of the feature that you can select table columns and have columns added with null values for columns that don't exist,

Code:
let
    Source = Table1,
    #"Filtered Rows" = Table.SelectRows(Source, each ([Category1] <> "catB")),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Item"}&List.Distinct(Table.SelectRows(Source,each [Category1] = "catB")[Item]), MissingField.UseNull),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns",{{"Item", "ItemDesc"}})
in
    #"Renamed Columns"
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,279
Members
449,075
Latest member
staticfluids

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