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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mkrmenci
New Member

Using Search function within Switch

Hi Folks,

 

I'm trying to create a new query that will search through a column looking for cells that contain specific text. I'm using the SWITCH function and so far its working great.  Example.

 

NewColumn =

SWITCH(

             TRUE(),
             TABLE1[ProcessColumn]="process.exe","Process Application", 

BLANK()

)

 

I would now like to add a search function this time as I want to find cells that may contain the text that I'm looking for. Basically like a wildcard or Like oeprator.  I've got this so far.

 

SWITCH (
              TRUE (),
              SEARCH ( "apache", 'TABLE1'[ProcessColumn],, 0 ) = 1, "Process Application",
BLANK()
)

 

It then throws me this error.

 

To use special characters in a column name, enclose the entire name in brackets ( [] ) and add a ] to any closing brackets in the name.

 

It could be something very obvious that I've done wrong but I've spent some time trying to get the right syntax and it still doesn't like it. Any ideas? Any help would be appreciated.

 

Thanks.

 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @mkrmenci

 

I have made a test with your dax expression in Power BI Desktop (Version: 2.56.5023.942 64-bit (March 2018)), everything works well. It seems that your formula should be right,

 

Untitled12.png

 

Please check if you have update the latest Power BI Desktop.

 

By the way, what is your data source and how do you connect it?

 

In addition, you could have a reference of my test pbix file.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @mkrmenci

 

I have made a test with your dax expression in Power BI Desktop (Version: 2.56.5023.942 64-bit (March 2018)), everything works well. It seems that your formula should be right,

 

Untitled12.png

 

Please check if you have update the latest Power BI Desktop.

 

By the way, what is your data source and how do you connect it?

 

In addition, you could have a reference of my test pbix file.

 

Best Regards,

Cherry

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

Hey @v-piga-msft ,

 

This solution seems to be working for me but with >1, instead of =1 : not sure why.

 

I also am not clear what is True() and Blank() doing in the code - those are not standard parameters for the SWITCH function, right?

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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