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
cmajewsk
Helper I
Helper I

Using the SWITCH Command with brackets in the name doesn't work

Hello, I am using the SWITCH command to normalize some company names. For example:

Normalized = SWITCH([Company],
"International Business Machines", "IBM",
"Microsoft", "MSFT"

 

 All is working well however, when I there is a bracket in the name it doesn't see it. For example:

Normalized = SWITCH([Company],
"Laboratory Corp. of America (Labcorp)", "LH")

In the filter cards it’s listed is a "Blank" 

There is no error on the DAX command. Any suggestions?

The data source cannot be changed so I am left with the brackets.

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @cmajewsk  ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution to help others find it.
 

Best Regard

Lucien Wang

v-luwang-msft
Community Support
Community Support

H@cmajewsk ,

I tried the dax you provided and it works.See the below:

v-luwang-msft_0-1614332683316.png

 

Check that the contents of the table match exactly what is used in Dax. And could pls provide your pbix file ? Remember to remove the confidential information.

 

Wish  it is helpful for you!

 

Best Regard

Lucien Wang

 

amitchandak
Super User
Super User

@cmajewsk , It should work , check for spaces

 

or try one of the two

 

Normalized = SWITCH([Company],
"Laboratory Corp. of America "(Labcorp")", "LH")

 

or

 

Normalized = SWITCH([Company],
"Laboratory Corp. of America \(Labcorp\)", "LH")

Thanks for the quick reply. Okay this is strange, neither work, however:

 

Laboratory Corp. of America "(Labcorp")", "LH") - this errors out the DAX

ERROR: The syntax for '(' is incorrect.

 

Using the backslash doesn't give me an error, but also doesn't change it and it still remains Blank in the filter cards. 

 

However, I don't know if I copied something wrorg or PBI added it but when I add "LH" front the backslash works. For example this works:

 "LH","Laboratory Corp. of America \(Labcorp\)", "LH")

Strange- but thank you!!

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.