Power Query to Dynamically Remove Unwanted Header Rows

legalhustler

Well-known Member
Joined
Jun 5, 2014
Messages
1,214
Office Version
  1. 365
Platform
  1. Windows
Hello PQ Gurus!

I need help in Power Query to dynamically remove unwanted row headers before I expand the 3 tables below and combine them (see below). The tables have the same columns once the unwanted rows above them are removed. I'm aware once this step is accomplished there will be duplicate headers from each of table somewhere below in each column, but I can easily filter them out in the next step. I'm guessing I need to add a custom column and somehow use some a function like Table.RemoveFirstN etc. To assist you, the unique first column header in each table should be "Company". So any data after the row "Company" is found in the first column the code should remove the rows above it for each table before I expand and combine the tables.


Data
Table1
Table2
Table3
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Are you sure you need to do this first? I would expand first, then edit the sample query, then come back and edit the combine query. More info here
 
Upvote 0
Are you sure you need to do this first? I would expand first, then edit the sample query, then come back and edit the combine query. More info here
That may be a bit too complex for a simple transformation step for what I'm doing.

I added a custom column and used the code below before I expanded my data and it removed all the unnecessary headers dynamically, but it only shows the header ("Company") and data for column 1 from each table. I just need to know how to modify the code below so it shows all the columns and it should work when I expand & combine the tables.

=Table.FromList(List.RemoveFirstN(Table.Column([Data],"Column1"), each _ <>"Company"))
 
Upvote 0
Could it be?
Power Query:
Table.PromoteHeaders(Table.Skip([Data], List.PositionOf([Data][Column1], "Company")))
Without Excel, so sorry if I goof up some syntax.
 
Last edited:
Upvote 0
Solution
Could it be?
Power Query:
Table.PromoteHeaders(Table.Skip([Data], List.PositionOf([Data][Column1], "Company")))
Without Excel, so sorry if I goof up some syntax.
Bingo! That did it. Thank you very much!
 
Upvote 0
Cool! Thanks for the feedback and mark.
 
Upvote 0

Forum statistics

Threads
1,223,657
Messages
6,173,633
Members
452,525
Latest member
DPOLKADOT

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