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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RafaelKnuth
Advocate I
Advocate I

M Power Query: Removing entire rows based on condition

I want to remove entire rows IF both horizontally adjacent cells in the last two columns are empty (hence rows 4, 6, 7, 9 should be removed). How can I do this? Not sure by the way whether I should do this in M or DAX. Any help appreciated. Thanks!

 

1 ACCEPTED SOLUTION

HI @RafaelKnuth

 

With Power Query...

 

You can add a Custom Column....>>>>then filter out the Null values in that column and then delete this Custom Column

 

removerows.png


Regards
Zubair

Please try my custom visuals

View solution in original post

5 REPLIES 5
Zubair_Muhammad
Community Champion
Community Champion

Hi @RafaelKnuth

 

Try this Calculated Table

From the Modelling Tab>>>NEW TABLE

(Replace TableName and Column names with actual names of your Table and Columns)

 

New Table =
FILTER (
    ADDCOLUMNS (
        TableName,
        "Remove Rows?", IF (
            ISBLANK ( TableName[Last Column] ) && ISBLANK ( TableName[2ndLast Column] ),
            "Yes",
            "No"
        )
    ),
    [Remove Rows?] = "No"
)

Regards
Zubair

Please try my custom visuals

HI @RafaelKnuth

 

With Power Query...

 

You can add a Custom Column....>>>>then filter out the Null values in that column and then delete this Custom Column

 

removerows.png


Regards
Zubair

Please try my custom visuals

Hi Zubar 

Do you mean that if I load 100,000 row table to power BI

if I want to delete from Row 5 till 100,000 , I can just write bSe on those script you share with me ?

That works nicely in Excel Power Query. Thank you!

Thanks, awesome! Any idea how to do that in the Excel source file? (it's not possible to create new tables in Excel Power Query ... in contrast to Power BI).

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.