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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Power Query AI: FilterNullAndWhitespace

Hi

I have a piece of M code that, I assume, was generated by AI.

In my Applied Steps it appears directly after the Navigation step.

Is someone out there able to explain what the 3 steps are doing.

The two steps afterwards, which I added, are both referring to the first step!  I've not seen this before.

 

FilterNullAndWhitespace = each List.Select(_, each _ <> null and (not (_ is text) or Text.Trim(_) <> ""))

 

Removed Bottom Rows = Table.RemoveLastN(Sheet1_sheet, each try           List.IsEmpty(List.Skip(FilterNullAndWhitespace(Record.FieldValues(_)), 1)) otherwise false)

 

Removed Bottom Rows = Table.RemoveLastN(Sheet1_sheet, each try     List.IsEmpty(List.Skip(FilterNullAndWhitespace(Record.FieldValues(_)), 1)) otherwise false)

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;


Is your problem solved? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ,

In my understanding, the first step is to convert the record to a list, determine whether the list is empty after skipping the first line, and then delete it.
Do you have all M codes to verify (sensitive information can be removed)?


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Are these part of the function?

each before List.Select is creating doubt

List.Select filter the data 

Table.RemoveLastN rows

 

_ as the first parameter in List.Select seem like it is part of a function

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi amitchandak

 

It does seem that the function is a precursor to determine which Rows to delete, but, I don't understand the syntax.

 

The two rows after the FilterNullAndWhitespace should have been:


#"Removed Bottom Rows" = Table.RemoveLastN(Sheet1_sheet, each try List.IsEmpty(List.Skip(FilterNullAndWhitespace(Record.FieldValues(_)), 1)) otherwise false),


#"Removed Top Rows" = Table.Skip(#"Removed Bottom Rows", each try List.IsEmpty(List.Skip(FilterNullAndWhitespace(Record.FieldValues(_)), 1)) otherwise false),

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.