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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBINoob24
Resolver I
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",
IF (FIND("@Domain4.com", table[Email Address],,0), "Canada", "US"))

1 ACCEPTED SOLUTION

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"
)

View solution in original post

5 REPLIES 5
Barthel
Solution Sage
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.

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

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"
)

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

That's the OR operator.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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