Forum Discussion
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
"[email protected]"
"[email protected]"
"[email protected]"
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
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"
4 Replies
- amitchandakSuper 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
- abeirneHelper II
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.- amitchandakSuper User
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"