The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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"))
Solved! Go to 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"
)
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
109 | |
80 | |
77 | |
46 | |
39 |
User | Count |
---|---|
137 | |
108 | |
64 | |
64 | |
53 |