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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
abeirne
Helper II
Helper II

Sorting usable customer emails from non-usable emails

Hi all, I have a large collection of customer emails, and I need to sort them from emails that are usable and those that are not. I have them all in one column, and I would like to search that column for text value "@" and ".com". This is because some of the values in the email column do not include these values, and so they aren't usable. For example, I want to gather all emails like 
"acb1234@gmail.com"
"tiger67@yahoo.com"
"78steelers@aol.com"
And not anything else, like phone numbers, blanks, or non-email addresses. Is there a way to do this? Let me know if you need additional information, thank you

1 ACCEPTED SOLUTION

@abeirne , Sorry Syntax issue .

correct one is

if Text.Contains([Column1],"@") and Text.Contains([Column1],".com") then 1 else 0

 

 

M test code

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSnRITErWS87PVYrViVZKcUgB8vJSS8C85LIkMG1oZKwUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Column1],"@") and Text.Contains([Column1],".com") then 1 else 0)
in
#"Added Custom"

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@abeirne ,  You can use filter in power query. USe custom option and use OR

 

or create a column like this

if Text.Contains("@",[Col])  or  Text.Contains(".com",[Col])  then 1 else 0

 

and filter row having value of this column =1  in power query

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

if Text.Contains("@",[Customer_Email_Address]) or
Text.Contains(".com", [Customer_Email_Address]) then [Customer_Email_Address] else "BBBB"

Unfornately that is only resulting in BBBB, I am not sure why, even when I change the 'or' to 'and'.

I also have this which is semi-working:
if List.AnyTrue(List.Transform( { "@" , ".com"}, (substring) => Text.Contains( [Customer_Email_Address], substring ) ) ) = true then [Customer_Email_Address] else "BBBBBB")

How to I add "and" in this? Right now it is pulling both values, resulting in outputs like "@DENIED" and other incorrect email addresses. Thank you for your help in this. 

@abeirne , Sorry Syntax issue .

correct one is

if Text.Contains([Column1],"@") and Text.Contains([Column1],".com") then 1 else 0

 

 

M test code

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSnRITErWS87PVYrViVZKcUgB8vJSS8C85LIkMG1oZKwUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Column1],"@") and Text.Contains([Column1],".com") then 1 else 0)
in
#"Added Custom"

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi thank you very much. Is there a way I can make a list of things not to include in results, as well as including and Text.Contains([Column1],"@"), etc?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.