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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
williamd40
Regular Visitor

How to change a parameter to replace characters and save it to a new parameter

Is there a way to change a string parameter to replace certain characters and then save this to a new parameter, such that if the first parameter is changed then the second one automatically updates as well? 

1 ACCEPTED SOLUTION

Hi! I was trying to create a parameter that was based off a user given string. This string is then passed into an sql query with a bunch of special characters escaped. I did this through passing it to the SQL query like "% stringName %" and then adding a bunch of .textReplace(). Like this:  "% stringName%.textReplace().textReplace().textReplace() %".

 

I was trying to get to a way of escaping those characters, this was the best solution I found

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

you cannot dynamically create parameters. Please provide a more detailed explanation of what you are aiming to achieve. What have you tried and where are you stuck?

Hi! I was trying to create a parameter that was based off a user given string. This string is then passed into an sql query with a bunch of special characters escaped. I did this through passing it to the SQL query like "% stringName %" and then adding a bunch of .textReplace(). Like this:  "% stringName%.textReplace().textReplace().textReplace() %".

 

I was trying to get to a way of escaping those characters, this was the best solution I found

I'm still not clear what you are trying to achieve. Can you give an example?

 

The scenario was:

User wants to know the count of a certain string based on an SQL query

That string my contain single and double quotes, and [ or ]

These needed to be escaped automatically prior to being passed into the sql query, and turned into a %

The user needed to be able to change the string on demand and then have power bi update the tiles

I was trying to find out how to be able to pass in this string as a parameter to the sql query in power bi, with those charcaters automatically escaped

In order to do this, I passed it into the query through a parameter, then used .textReplace() a bunch of times to escape all those characters

I was originally trying to use a power bi M query to achieve this, however the parameter wasn't being successfully updated

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.