cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
emudria Member
Member

Switch function - with a wild card or without exact expression

Hi Community

I am working on an experession, where I am using a switch - True function. 

Basically I have various columns with string values and I am trying to create a new column based upon values in these columns.

 

I am working something like this

 

custom column  = SWITCH( TRUE(),

                           OR('MyTable'[Col1] = "Organic Search" , ''MyTable'[Col2] =  "google.com.au") ,"Search",

                                 'MyTable'[Col2] = "facebook.com" , "social",

                                 'MyTable'[Col3] = "%mySTRING%" , "myResults"

)

 

In this above expression, I want to work for the last line Italic, where I am do not have exact match but only a part of the expression. I can not figure out how to build the expression, as we do regexp or like in SQL.

 

Any help, hints, direction would be highly appriciated.

regards.

 

                                                                       

1 ACCEPTED SOLUTION

Accepted Solutions
v-jiascu-msft Super Contributor
Super Contributor

Re: Switch function - with a wild card or without exact expression

Hi @emudria,

 

Function "Search" could help in your scenario. Please have a try.

 

custom Column =
SWITCH (
    TRUE (),
    OR ( 'Table3'[Col1] = "Organic Search", 'Table3'[Col2] = "google.com.au" ), "search",
    'Table3'[Col2] = "Facebook.com", "social",
    SEARCH ( "test", 'Table3'[Col3], 1, 0 ) > 0, "myresults"
)

 

Switch function - with a wild card or without exact expression.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-jiascu-msft Super Contributor
Super Contributor

Re: Switch function - with a wild card or without exact expression

Hi @emudria,

 

Function "Search" could help in your scenario. Please have a try.

 

custom Column =
SWITCH (
    TRUE (),
    OR ( 'Table3'[Col1] = "Organic Search", 'Table3'[Col2] = "google.com.au" ), "search",
    'Table3'[Col2] = "Facebook.com", "social",
    SEARCH ( "test", 'Table3'[Col3], 1, 0 ) > 0, "myresults"
)

 

Switch function - with a wild card or without exact expression.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

Best Regards!

Dale

 

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

emudria Member
Member

Re: Switch function - with a wild card or without exact expression

Thank you @v-jiascu-msft, seems what I was after. Will give it a try.

 

jschlereth Member
Member

Re: Switch function - with a wild card or without exact expression

@v-jiascu-msft,

Nicely done. In essence allows us to do a "like" within a switch statement. 

Just what I needed.

 

Jonathan 

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 221 members 2,281 guests
Please welcome our newest community members: