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

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.

Reply
Anonymous
Not applicable

Create emails & exclude null values - Power Query

Is there a way to create the custom column in yellow, excluding the null values? I'm not sure if this is even ahievable in Power Query.. any advice would be appreciated. 

 

yham1023_0-1672859404033.png

 

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Anonymous ,
you can add a custom column with the following formula:

Text.Combine(List.Select( Record.FieldValues( Record.RemoveFields(_, {"ID"}) ), (l) => l <> null), "@gmail.com%2C") & "@gmail.com"

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

View solution in original post

4 REPLIES 4
ImkeF
Community Champion
Community Champion

Sure:
The _ gets all fields from the current row in a record format.

But we don't need the ID-column. So we the Record.RemoveFields function removes just that field.
Then the Record.FieldValues-function transforms that record into a list, containing only the field values.

But there are nulls in there that shouldn't be used to create the final string.
Therefore we use the List.Select function with (l) => l <> null as function argument: l stands for each item in the list and I <> null means that only items that are not null will be kept.

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

AlexisOlson
Super User
Super User

@ImkeF's answer looks good except that the ID = 444 row returns "@gmail.com".

 

Here's a slightly different approach that applies the "%2C" and "@gmail.com" separately:

Text.Combine(List.Transform({[name1], [name2], [name3], [name4]}, each _ & "@gmail.com"), "%2C")

 Note that null & "@gmail.com" returns null.

ImkeF
Community Champion
Community Champion

Hi @Anonymous ,
you can add a custom column with the following formula:

Text.Combine(List.Select( Record.FieldValues( Record.RemoveFields(_, {"ID"}) ), (l) => l <> null), "@gmail.com%2C") & "@gmail.com"

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

Anonymous
Not applicable

this worked like a charm! could you explani what the query is doing? I'm trying to understand this part "

 Record.RemoveFields(_, {"ID"}) ), (l) => l <> null

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors