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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register 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
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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