Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

I want to write string with both Single and Double quotes in Filter expression editor

VijayAnaparthi
8 - Asteroid

I want to Keep both Single quotes and Double quotes in Filter expression editorString_Quotes_Error.JPG

12 REPLIES 12
DataNath
17 - Castor
17 - Castor

Iirc you’d need to split this into multiple parts where you’re using one or the other, wrapping “ in ‘ and vice versa. In this example I think it’d be:

 

[Field 1] = ‘“What if I want both ’+”’single quotes’ and “+’”double quotes” in a string”’

binuacs
21 - Polaris

@VijayAnaparthi  as @DataNath mentioned you need to give part of the sentence in the custom filter 

binuacs_0-1656768471233.png

 

VijayAnaparthi
8 - Asteroid

I understand above solution, but my problem was i am creating app and it has dropdown with multiple strings(records) like above. So user will select one value from that dropdown and that user selected value will come to this filter tool because i am using replace specific string in action tool. So every time user will select different string and each string has different number of quotes and in different positions. So i am not understanding how to tackle that problem.

DataNath
17 - Castor
17 - Castor

@VijayAnaparthi I can think of 2 immediate workarounds for this (as the above solutions obviously won’t work for single dropdown selections):

 

Use a Formula tool to make a copy of your target string field (for example we’ll just call it [Filter]), and either a) use a replace function to replace all “ with ‘, or all ‘ with “, or b) use a Cleanse Data tool to remove all punctuation.

 

Use the replaced or cleansed version of the string field - [Filter] to feed your dropdown, and then you can use [Filter] = ‘x’ in your filter expression, where ‘x’ is the replaced or cleansed value.

 

If you replace all ‘ with “ then you’ll obviously need to wrap ‘x’ in single quotes and vice versa if you replace all “ with ‘. If you cleanse and remove all punctuation, you can use it other “x” or ‘x’.

VijayAnaparthi
8 - Asteroid

I don't want to loose any single and double quotes from my string. I want exact string that how it is presented in dropdown.

DataNath
17 - Castor
17 - Castor

Hey @VijayAnaparthi I managed to put something together that will handle this. The values in your dropdown will still appear as normal with double and single quotes mixed, as will your underlying data and the output. All this does is use replace functions to bring the two strings to the same format for the sake of the filter, which doesn't change the appearance of them anywhere else.

 

DataNath_0-1656775618728.png

DataNath_1-1656775630719.png

DataNath_2-1656775654101.pngDataNath_3-1656775667226.pngDataNath_4-1656775682107.pngDataNath_5-1656775704258.png

VijayAnaparthi
8 - Asteroid

Thank You @DataNath It is working. I appreciate your help.

VijayAnaparthi
8 - Asteroid

Hi @DataNath, Above solution is working perfectly for filter tool. But i am facing one more problem which is lets say i am having one text box which will update the string that we selected from dropdown(here user is entering string from his side in textbox) then above thing wont work(Also i am using formula tool instead of filter). I attached workflow and error.

DataNath
17 - Castor
17 - Castor

@VijayAnaparthi if you're always going to be replacing this with strings in double quotes then all you need to do is change your Formula to 'x' with single quotes, instead of double. The other way round if you're always replacing with single quoted strings. If not, the issue goes back to my first response to my thread in that you need to wrap double quotes in singles and vice versa, so currently when you try and place "Double quotes" into "x" by replacing the x, this string will become ""Double quotes"". Alteryx will read the replacement as the initial "" (before D) and the rest of the text will be there pertaining to nothing, throwing an error. Because of this, I can't think of a way to dynamically level this out. With your filter, we could temporarily change it to satisfy the Filter tool. However, for the sake of a Formula that replaces the existing value, you'd need to do something like my first response where you basically have to stitch the string together because of the mixed quote types: 

 

DataNath_0-1656926075783.png

Labels
Top Solution Authors