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
HakamAbushanab
Regular Visitor

Remove empty Tip on Power Query

g.png

 

When cleaning up your datasets in #PowerQuery, the default option "Remove empty" is often used to eliminate blank rows. However, there's a caveat to be aware of: not all "blanks" are truly empty. Some may just be spaces which the default option won't catch.

To ensure a comprehensive cleanup, modify your M code as follows:

**Original Code:**
```m
= Table.SelectRows(#"Removed Columns2", each [Sales Doc.] <> null and [Sales Doc.] <> "")
```

**Improved Code:**
```m
= Table.SelectRows(#"Removed Columns2", each [Sales Doc.] <> null and [Sales Doc.] <> "" and [Sales Doc.] <> " ")
```

This enhancement ensures that rows with spaces posing as "blanks" are also removed, leading to a cleaner dataset.

---

Hope this helps, and happy data cleaning! 🙂
.
.
.
.
.
.
#powerbi #dataanalytics #dataanalyst

2 REPLIES 2
mlsx4
Memorable Member
Memorable Member

Hi @HakamAbushanab 

 

There is also a good option which is TRIM everything to avoid unnecessary characters 😉https://radacad.com/trim-vs-clean-in-power-bi-and-power-query

Hello Rada,

Upon reviewing your website, I noted that the trim function is an effective solution for eliminating superfluous characters, as you mentioned. It appears that your dataset contains some unnecessary characters on certain rows. Conversely, in my dataset, I observed purely blank rows. By employing the default 'delete nulls' option in Power BI, I was able to remove a majority of the nulls present in the files. However, some of the rows that seemed to be nulls were actually spaces, which led me to enhance the code with an additional condition to eliminate spaces: [Sales Doc.] <> " "      : )

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