Share via

How do I replace nulls with errors in Power Query?

Anonymous
2023-11-25T19:56:25+00:00

Hi there,

I need to replace all nulls in all the columns of my table with errors so that I can then use Table.RemoveRowsWithErrors. (I don't want to replace errors with nulls, nor to replace nulls with the string "errors".)

Thanks in advance.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Lz365 38,201 Reputation points Volunteer Moderator
2023-11-26T08:58:26+00:00

Hi Jesus

How do I replace nulls with errors in Power Query?

If you succeed in doing this let me know I'm more than interested (curiosity). Don't get me wrong, I'm not saying this is mission impossible, they are very creative people...

(+ doing such replacement might be inefficient on a large table)

I need to replace all nulls in all the columns of my table with errors so that I can then use Table.RemoveRowsWithErrors

As I understand this - ultimately - means filtering out rows containing >/1 null, something not doable with Power Query UI option Remove Blank Rows:

Image.

FilteredRows = Table.SelectRows(<Previous Step Name>,

(rec) =&gt; not List.Contains(Record.ToList(rec), null) 

),

Or, if this talks better to you:

FilterRowsTwo = Table.SelectRows(<Previous Step Name>,

each not List.Contains(Record.ToList(\_), null) 

),

Corresponding sample available here

EDIT: Sample updated. Includes version with the UI only. See query RemovedRowsWithAnyNull_UI

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Lz365 38,201 Reputation points Volunteer Moderator
    2023-12-04T23:30:39+00:00

    Hi Jesus

    No new for a week :( Good/Bad news? Whatever, any feedback will help people who Search

    Thanks in advance

    Was this answer helpful?

    0 comments No comments
  2. Ashish Mathur 102K Reputation points Volunteer Moderator
    2023-11-25T23:01:46+00:00

    Hi,

    Your question is not clear. Why can you simply not filter out the rows which have nulls? Could you share some data and show the expected result.

    Was this answer helpful?

    0 comments No comments