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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
JPSingh
Frequent Visitor

Formula for IF text equal or another text contains else IF

Hi there. I am trying to replicate a formula I use in excel but I am struggling to get this formula right into BI. I am not sure if this should be done in power query or DAX but I don't seem to be able to replicate this. Is anyone able to advise the best was about getting this formula in BI:

 

If ProjectType "Credit Project" 
THEN IF Name contains "Managed Services" THEN "Credit - Managed Services" ELSE "Credit - Other" 
ELSE IF Name contains "Client" THEN "Client" ELSE IF "Invoiced?" = "Yes"
THEN "Invoiced" ELSE IF LEFT (Name) = "Time off" OR LEFT (Name) = "Annual Leave"
THEN "Leave" ELSE "Unmapped"

 

Is this formula at all possible to do or would I need to break this down.  

1 ACCEPTED SOLUTION
dharmendars007
Super User
Super User

Hello @JPSingh , 

 

Give the below code a try 

 

NewColumn =
IF(
'TableName'[ProjectType] = "Credit Project",
SWITCH(
TRUE(),
CONTAINSSTRING('TableName'[Name], "Managed Services"), "Credit - Managed Services",
CONTAINSSTRING('TableName'[Name], "Client"), "Client",
'TableName'[Invoiced?] = "Yes", "Invoiced",
LEFT('TableName'[Name], 8 )= "Time off" || LEFT('TableName'[Name], 12) = "Annual Leave", "Leave",
"Unmapped"),
BLANK() // or some other default value if ProjectType is not "Credit Project")

 

If you find this helpful , please mark it as solution and Your Kudos are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

View solution in original post

2 REPLIES 2
JPSingh
Frequent Visitor

Thank you. I have made some adjustments on the formula but this works 🙂

dharmendars007
Super User
Super User

Hello @JPSingh , 

 

Give the below code a try 

 

NewColumn =
IF(
'TableName'[ProjectType] = "Credit Project",
SWITCH(
TRUE(),
CONTAINSSTRING('TableName'[Name], "Managed Services"), "Credit - Managed Services",
CONTAINSSTRING('TableName'[Name], "Client"), "Client",
'TableName'[Invoiced?] = "Yes", "Invoiced",
LEFT('TableName'[Name], 8 )= "Time off" || LEFT('TableName'[Name], 12) = "Annual Leave", "Leave",
"Unmapped"),
BLANK() // or some other default value if ProjectType is not "Credit Project")

 

If you find this helpful , please mark it as solution and Your Kudos are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors