cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Resolver I

## Creating a Column using a Nested Find

Hello all:

I'm trying to create a column where the value will be based off and email domain. The below is what I have, but it keeps throwing an error.

Country = IF (FIND("@Domain1.com",
IF (FIND("@Domain2.com",
IF (FIND("@Domain3.com",

1 ACCEPTED SOLUTION
Solution Sage

So, if the domain is equal to one of the four then it is Canada otherwise US? Maybe this will work for you:

Column =
IF (
CONTAINSSTRING ( 'Table'[Email Address], "@Domain1.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain2.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain3.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain4.com" ),
"Cananda",
"US"
)
5 REPLIES 5
Solution Sage

Hey @PowerBINoob24,
I'm not sure if this is what you're looking for. But you could work with a SWITCH statement. This sets a number of conditions. The first condition that is true is returned. For example:

Column =
SWITCH (
TRUE,
CONTAINSSTRING ( 'Table'[Email Address], "@Domain2.com" ), "Cananda",
CONTAINSSTRING ( 'Table'[Email Address], "@Domain3.com" ), "US"
)

If the mail column contains '@Domain2.com' then 'Canada', if the column contains '@Domain3.com' then 'US' etc.

Resolver I

That's not quite what I need.  Need to find the four specific domains, not just the first one it finds.

Solution Sage

So, if the domain is equal to one of the four then it is Canada otherwise US? Maybe this will work for you:

Column =
IF (
CONTAINSSTRING ( 'Table'[Email Address], "@Domain1.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain2.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain3.com" )
|| CONTAINSSTRING ( 'Table'[Email Address], "@Domain4.com" ),
"Cananda",
"US"
)
Resolver I

Thanks!  That got it.  What is the purpose of the double pipes at the beginning of the lines?

Super User

That's the OR operator.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors