Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
TiZi08
New Member

Remove Rows & Use First Row as Headers for Specific Columns

Hi.

 

I want to Remove Rows & then Use First Row as Headers for specific columns. Specifically, I want to apply this to all except two columns.

I am working with messy data; at least the data is consistently messy so I know the data I am reading will always be weirdly structured like this.

 

For e.g. below, Col 1 and Col 6 I want to leave as-is but I want to remove the first 6 rows & then apply the Use First Row as Headers to columns 2 to 5. Preferably, I would not want to manually specify each column to apply the actions to (as the data can have up to 150+ columns) & instead be able to specify the columns I don’t want the actions applied to.

 

Col 1Col 2Col 3Col 4Col 5Col 6
Do NOT apply remove rows & use first row as headerAPPLY remove rows & use first row as headerAPPLY remove rows & use first row as headerAPPLY remove rows & use first row as headerAPPLY remove rows & use first row as headerDo NOT apply remove rows & use first row as header
1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

NewStep=let ColumnNamesYouWantKeep={"Col 1","Col6"},Rows=Table.ToRows(PreviousStepName) in #table(List.Transform(List.Zip({Table.ColumnNames(PreviousStepName),Rows{5},List.Positions(Rows{0})}),each if List.Contains(ColumnNamesYouWantKeep,_{0}) then _{0} else Text.From(_{1}??Number.ToText(_{2}+1,"Column_0")),List.Skip(Rows,6))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors