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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors