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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
aso1
Helper II
Helper II

if statement column

I have a column with different usernames. some contain some prefixes such as "DOMAIN\" and others dont have these prefixes. 

I want a custom column that attaches a text if X is something.  Exactly like this : 

 

Desired output :

if Name starts with 'NT SERVICE' or 'NT Authority' then type 'SQL System'

if Name starts with 'DOMAIN\' then type 'Windows Authentification'

if Name starts does NOT start with "DOMAIN" - then type SQL Authentification'

 

 

powerbi_customcolumnfor SQL_WindowsUsers.jpg

 

how can I achieve this? I would like to create a custom-column preferably. 

 

thanks!

 

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @aso1 ,

 

Try this for a custom column on Power Query:

 

if Text.StartsWith(Text.Upper([Column1]), "NT SERVICE")
or Text.StartsWith(Text.Upper([Column1]), "NT AUTHORITY")
then "SQL System"
else
if Text.StartsWith(Text.Upper([Column1]), "DOMAIN\") then
"Windows Authentication"
else "SQL Authentication"



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @aso1 ,

 

Try this for a custom column on Power Query:

 

if Text.StartsWith(Text.Upper([Column1]), "NT SERVICE")
or Text.StartsWith(Text.Upper([Column1]), "NT AUTHORITY")
then "SQL System"
else
if Text.StartsWith(Text.Upper([Column1]), "DOMAIN\") then
"Windows Authentication"
else "SQL Authentication"



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Pragati11
Super User
Super User

HI @aso1 ,

 

You can create a calculated column using DAX as follows:

 

ifContainsString = IF(CONTAINSSTRING(youTable[Name], "NT SERVICE") = TRUE() || CONTAINSSTRING(youTable[Name], "NT Authority") = TRUE(), "SQL System", 
IF(CONTAINSSTRING(youTable[Name], "DOMAIN\") = TRUE() , "Windows Authentification", "SQL Authentification"))
 
Thanks,
Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors