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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

Conditonal Column based on a string

Morning All

 

Im sure there is an easy way to do this.

 

Maybe using a switch function as that can cater for blanks?

 

I have a table that will have data like that in Table 1 Column 1

 

I want to add a new conditional column 2 which will do the following:

 

If it finds the String ITC then in the new conditional column it will output IT Component

If it finds the String APP then in the new conditional column it will output IT Application

 

Excel Mock Up

 

jimmyg706_0-1710314034648.png

 

 

 

Table 1 – Current

 

Data Source
APP-51059
APP-51026
APP-51037
APP-51040
ITC-92620
ITC-92338
ITC-92828

 

 

Table 2 – Required

 

Data SourceNew Conditional Column
APP-51059IT Application
APP-51026IT Application
APP-51037IT Application
APP-51040IT Application
ITC-92620IT Component
ITC-92338IT Component
ITC-92828IT Component

 

 

Any pointers appreciated.

 

Jimmy

 

1 ACCEPTED SOLUTION
dk_dk
Super User
Super User

Hi @Anonymous ,

You can do this in Power Query as well with a conditional column, but if you want to add a DAX calculated column you can try this:

 

Conditional Column = 

SWITCH(TRUE(),
CONTAINSSTRING(Source[Data Source],"APP"), "IT Application",
CONTAINSSTRING(Source[Data Source],"ITC"), "IT Component",
"Other")


You can replace "Other" with just "" if you want to show blanks on no match, and you can also expand the switch statement to search for additional strings and display a different result.

 




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
dk_dk
Super User
Super User

Hi @Anonymous ,

You can do this in Power Query as well with a conditional column, but if you want to add a DAX calculated column you can try this:

 

Conditional Column = 

SWITCH(TRUE(),
CONTAINSSTRING(Source[Data Source],"APP"), "IT Application",
CONTAINSSTRING(Source[Data Source],"ITC"), "IT Component",
"Other")


You can replace "Other" with just "" if you want to show blanks on no match, and you can also expand the switch statement to search for additional strings and display a different result.

 




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

Proud to be a Super User!





And here is how you would need to configure a conditional column in Power Query instead:

dk_dk_0-1710318016470.png

Hope this helps.




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

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon & SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.