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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

check if columns are blank/null

I need to find records where a group of columns all contain "null" values. If the specified columns only contain null values, then evaluate as false. If columns contain any value (ie <> blank), evaluate as true.

 

ABCDresult
sunnynullrainynulltrue
nullnullnullnullfalse

 

Surely there must be a better way to determine this without merging cell values?

 

I would like to do something like:

 

= Table.AddColumn(#PreviousStep, "result", each if column in list <> null then true else false)

 

Where "list" is another referenced query with a list of the column names I want to apply the function to.

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use below in your custom column where Query1 holds the list of columns

List.RemoveNulls(Record.ToList(Record.SelectFields(_, Query1))) <> {}

View solution in original post

6 REPLIES 6
Rickmaurinus
Helper V
Helper V

Hi brendo,

 

You can paste below formula into the custom column formula box: 

if List.NonNullCount (Record.FieldValues ( Record.SelectFields ( _, YourList ) ) ) = 0 then false else true

What this statement does is this: 

  • First Record.SelectFields retrieves the record fields (row values in your table) of all columns specified in 'YourList'. In this case 'YourList' should be a reference to the other query
  •  Record.FieldValues then returns the values from the record fields as a list
  • List.NonNullCount then counts how many items are not null. If none of them are, you can return false like said in your requirements.

 

Just make sure to change the 'yourlist' value to the list of columnnames you had in mind. 

Do you need any additional help? 

 

Rick

 

--------------------------------------------------

@ me in replies or I'll lose your thread

 

Master Power Query M? -> https://powerquery.how

Read in-depth articles? -> BI Gorilla

Youtube Channel: BI Gorilla

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly.

Vijay_A_Verma
Super User
Super User

Use below in your custom column where Query1 holds the list of columns

List.RemoveNulls(Record.ToList(Record.SelectFields(_, Query1))) <> {}
Anonymous
Not applicable

I attempted this, but I am getting the incorrect number of blank rows (did a function in R to check for blank rows and R is showing me double the number of rows than in power query, and I am analyzing the same dataset in R). Could you explain step by step what your query does? 

Query1 should be a list.

What it would do is to perform row wise operation.

For a row, it will select only those fields which are present in Query1. 

It will convert this record into list. Hence, the list will contain only those values whose columns were present in Query1.

It will remove all nulls from this list and it will be compared to check whether the list is blank or not.

If list is blank it means all values were nulls. Hence, it will give false.

If there is even a single value, it will give true.

ToddChitt
Super User
Super User

Not sure I understand your goal. You have a Reference list of data, say it contains rows with values "A" and "B" (rows not columns) Is that right?

And you want to manipulate the rows in this table, say, remove "A" and add "C", and have the results of the main query change to only look at columns B and C in the Power Query?




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Anonymous
Not applicable

I have a list of 25 column names. 

I have a dataset that has 100 columns. I want to check, for every row, whether there is data in any of those 25 columns. If there is a value in one of those 25 columns, return TRUE in new column. If that record only contains null values in those 25 columns, return FALSE. 

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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