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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
sevenhills
Super User
Super User

Remove relative rows dynamically

Hi,

 

Remove relative rows dynamically

In Power Query, I want to remove relative rows based on certain conditions. Once identifying the first row of a set, how to remove the row and the next relative rows dynamically?

 

Let us say, I am processing files in a folder and are combined in one table and as 

File 1 - 47th row as "first set" first row, 154th row as "second set" first row

File 2 - 42th row as "first set" first row, 154th row as "second set" first row

File 3 - 41th row as "first set" first row, 161th row as "second set" first row

 

I am able to identify the first row of each set of rows easily. Following 7 or 5 rows is no easy way to identify as it has dynamic text, except the fact fixed number of rows.

 

I need to delete the rows as 

       File 1 - Delete rows with rownumber as 47 +7 rows, 154+5 rows 

       File 2 - Delete rows with rownumber as 42 +7 rows, 154+5 rows 

       File 3 - Delete rows with rownumber as 41 +7 rows, 161+5 rows 

 

After getting the first row number in each set, How to remove relative rows dynamically?

 

TIA

1 ACCEPTED SOLUTION

Try adding a custom column to the table:

{[Row Begin]..[Row End]}

and then expand that column into rows so that it looks like this:

AlexisOlson_0-1637778673856.png

 

Then you can add an index column on your data table that indexes each distinct File Name and do a Left Anti join to remove any rows in that table that match the custom column in the expanded table above.

View solution in original post

3 REPLIES 3
sevenhills
Super User
Super User

Thank you it worked. 

sevenhills
Super User
Super User

I am able to get through Power Query "M" (at run time) as 

 

Delete Row Details as

File NameSet NameRow BeginRow End
File 1Set 14754
File 1Set 2154159
File 2Set 14249
File 2Set 2154159
File 3Set 14148
File 3Set 2161166

(FYI, I have over 100 files+ that will get into dataset and I can determine the rows that need to be deleted in each file in power query.)

 

Using the above table in power query, how to delete rows based on row numbers in the below dataset? 

File NameRow Number
File 11
File 12
File 13
File 1
File 21
File 22
File 23
File 2
File 31
File 32
File 33
File 3

 

 

Try adding a custom column to the table:

{[Row Begin]..[Row End]}

and then expand that column into rows so that it looks like this:

AlexisOlson_0-1637778673856.png

 

Then you can add an index column on your data table that indexes each distinct File Name and do a Left Anti join to remove any rows in that table that match the custom column in the expanded table above.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors