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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
csinusa
Frequent Visitor

Split string and add single quotes

Hi, 

In my paginated report, one of the parameters has input value as:

'abc,def,ghi'

 

but I want it to be parsed and make the parameter value as:

'abc','def','ghi' 

 

So I can use these with IN

 

I tried 

=Join(Split( Replace(Parameters!SiteIdList.Value, ",","','") ,"',"), ",")

 

But then powerbi adds escape character with my quotes making the output as :

'\'abc\',\'def\',\'ghi\'

 

which makes it useless.

 

Any suggestion

 

 

1 ACCEPTED SOLUTION

Yes, it was the data provider (Simba Odbc driver) that was escaping single qoute after I was replacing , with ',' 

Had to use expression in Query text to pass my complete query as a string which then worked.

csinusa_0-1690417754023.png

 

View solution in original post

2 REPLIES 2
d_gosbell
Super User
Super User

Where are you seeing these escape characters? I just used the inner Replace() call from your example as the split then join seems redundant and I don't see any escaping going on. The top line below is the original parameter value and the bottom line is a text box using replace(). It possibly also depends how you are using this parameter are you concatenating it into your query with an expression or are you passing it into another parameter in the query? It could be the data provider doing the escaping to prevent SQL injection. 

d_gosbell_0-1690353742839.png

 

Yes, it was the data provider (Simba Odbc driver) that was escaping single qoute after I was replacing , with ',' 

Had to use expression in Query text to pass my complete query as a string which then worked.

csinusa_0-1690417754023.png

 

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.