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
ChrisBernatek
Frequent Visitor

Validating email values using a calculated column?

Hello,

 

I have a dataset taken from our customer database that contains a field called "email".

 

What I want to do in the Power Query Editor is to create a calculated column that checks if the value in that email field is valid (in terms of syntax) ie the value follows the structure of: "name"@"domain"."extension"

 

I stumbled across some code on stack overflow which is similar to what I am after but this code requires the email address text to be manually entered. I just want it to take the text from the email field and to run that through the validation process and then the output should either be "Valid" or "Invalid".

 

let
    IsValidEmail = (input as text) =>
    let
        name = Text.BeforeDelimiter(input,"@",{0,RelativePosition.FromEnd}),
        ext = Text.AfterDelimiter(input,".",{0,RelativePosition.FromEnd}),
        domain = Text.BetweenDelimiters(input,name&"@","."&ext),
        return =
            Text.Length(name) > 0 and
            Text.Length(domain) > 0 and
            Text.Length(ext) > 1 and Text.Length(ext) < 6 and
            name = Text.Select(name, {"a".."z","A".."Z","0".."9","_","-","."}) and
            domain = Text.Select(domain, {"a".."z","A".."Z","0".."9","_","-","."}) and
            ext = Text.Select(ext, {"a".."z","A".."Z"})
    in
        return
in
    IsValidEmail

 

Can anyone provide the correct code please?

 

Cheers 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @ChrisBernatek ,

 

You just need to change the last line of code to IsValidEmail([email]), which will call the function.

 

vkkfmsft_0-1656664974065.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-kkf-msft
Community Support
Community Support

Hi @ChrisBernatek ,

 

You just need to change the last line of code to IsValidEmail([email]), which will call the function.

 

vkkfmsft_0-1656664974065.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fantastic, you are a life (well time!) saver, thanks so much for posting 🙂 

Yes, works perfectly.

 

Many thanks

amitchandak
Super User
Super User

@ChrisBernatek , refer if this can help

https://bielite.com/blog/email-validation-in-power-bi/

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I had seen that but I am not wanting to push my data out to a third party API.

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! Prices go up Feb. 11th.

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.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.