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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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 Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 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.