Alteryx Designer Desktop Discussions

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

How do i escape a single quote in alteryx?

mwenmad
5 - Atom

I've created an if-then formula to rename some units. however one of the unit names contains an apostrophe and that is causing an error. How do i get around that?

ELSEIF (Contains('4371-The Women's Place', [CurrentUnitName]))
THEN 'The Women's Place'

4 REPLIES 4
StephenR
Alteryx
Alteryx

If you have a single quote in the string, then use double quotes around the string.  Alternatively, if you have a double quote in the string, use single quotes around the string.

Regards,
Stephen Ruhl
Principal Customer Support Engineer

db-DCA
5 - Atom

What if you have both single and double quotes in a string?

hroderick-thr
11 - Bolide

when you have both types...

You can split your string into

parts with ' bounded by " and

parts with " bounded by '

then concatenate the parts with a +

 

I just got this example to work

 

"max(case when Attribute = '" 

+ [Name]

"' THEN Value_Varchar ELSE NULL END ) AS "

+ '"'+ [Name] + '"'

 

Results look like

MAX(CASE WHEN Attribute = 'Busines SLA' THEN Value_Varchar ELSE NULL END ) AS "Busines SLA",

G1
8 - Asteroid

Hi,

 

Does anyone know why the escape character \ would not work for this situation?

 

For example, why would the following not work? The escape character should tell Alteryx/regex that you are wanting to identify hyphens in a string:

 

Doesn't work: REGEX_Replace([test], '[ ' ]', 'xxx')...i understand that this should not work

Doesn't work: REGEX_Replace([test], '[ \' ]', 'xxx')...but here I am escaping the hyphen so this hyphen should be interpreted as a hyphen and not the end of the regex expression

 

**I am aware that REGEX_Replace([test], "[ ' ]", 'xxx')...surrounding the expression in quotes... works fine. But that's not what i want to know. Specifically I want to know why the escape character, which should work, does not in this situation

 

Thanks

Labels