Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a simple query step:
NextStep = Table.SelectRows(LastStep, each ([Email] <> null))
Now I want the string "Email" to come from another query called "ColumnName". How do I evaluate ColumnName inside the [] to get the word "Email"?
Solved! Go to Solution.
NextStep = Table.SelectRows(LastStep, each (Record.Field(_, ColumnName) <> null))
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @freelensia
Is this problem sloved?
If it is sloved, could you kindly accept it as a solution to close this case?
If not, please let me know.
Best Regards
Maggie
NextStep = Table.SelectRows(LastStep, each (Record.Field(_, ColumnName) <> null))
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Thanks @ImkeF
I understand the ColumnName is coming from another query. So if I want to filter records where Email <> null, I have to make sure ColumnName query evaluates to "Email" finally.
Could you explain _ here?
I understand that Record.Field has 2 inputs, the first needs to be a single record (one row), the second is the column we want to check. But what is the connection with _ and how does this each function evaluate to "[Email]" so that we can check whether [Email] <> null or not.
Hi @freelensia
in this case, the _ stands for each record in the table.
Please find further details here: https://www.excelguru.ca/blog/2018/01/09/each-keyword-power-query/
Just replace "ColumnName" by a reference to the object that contains the column name you're after.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @freelensia
I know how to get a column from another query in Power Query,
Power Query : add column getting value from another one in an another table not related
But I don't know what's purpose you use another query's column in your code.
If you could tell me more clearly, i can modify with your formula.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the answer. I am building an Excel module to pass on to some users. The user will select the column they want to filter for blanks. Say it could be "Email" or "Phone" or "Name". This text value will feed into Power Query via a named range. Then I want to refresh the query to filter for [ColumnName] = null where ColumnName was specified by the user in Excel.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!