Alteryx Designer Desktop Discussions

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

Insert square brackets and double quotes to a string

spuri5
7 - Meteor

Hello Alteryx Community,

 

My current output is looking like this in JSON format as shown below:

Current Output 1
"Name": "AAA","BBB","CCC"

Current Output 2
"Name":""

Current Output 3
"Name":"HHH"

 


The expected output should be like as shown below:

Expected Output1
"Name": ["AAA","BBB","CCC"]

Expected Output2
"Name": [""]

Expected Output3
"Name": ["HHH"]

 

 

Thank you!

11 REPLIES 11
CathyS_Slalom
9 - Comet

Hi @spuri5, If it always start with "Name": you can use the formula below

 

CathyS_Slalom_0-1654631862197.png

 

spuri5
7 - Meteor

Hello Cathy, 

 

Thank you for the reply,

 

But the Name string value is not always 3 digits.

 

Please advise! 

CathyS_Slalom
9 - Comet

Hi @spuri5 , if that's the case, please use the formula below (locate the : to get the dynamic name length):

ReplaceFirst([Old], left([Old],FindString([Old], ":")+1), left([Old],FindString([Old], ":"))+ ":[") + "]" 

CathyS_Slalom_0-1654633139143.png

 

binuacs
20 - Arcturus

@spuri5 Another way of dong this with the RegexReplace formula

 

binuacs_0-1654633921204.png

 

spuri5
7 - Meteor

Hi Cathy,

 

With the below formula, the output I am getting:

 

Current Output 1

"Name": "AAA,BBB,CCC]",

"Name":"]",

"Name":"HHH]",

 

But the expected output should be as shown below:

 

Expected Output1
"Name": ["AAA","BBB","CCC"],

"Name": [""],

"Name": ["HHH"],

spuri5
7 - Meteor

Hi @binuacs ,

 

With the below formula, the output I am getting: 

 

Current Output 1

 

"Name": "AAA,BBB,CCC:[AAA,BBB,CCC]",

"Name":":[]",

"Name":"HHH:[HHH]",

 

But the expected output should be as shown below:

 

Expected Output1

 

"Name": ["AAA","BBB","CCC"],

"Name": [""],

"Name": ["HHH"],

CathyS_Slalom
9 - Comet

Hi @spuri5 If your input data is matching the pattern that under Old column, and you use the function in the picture, you should be able to see the expected output as shown under the "New" column. Could you make sure that you applied this new formula after your previous/current output that you listed below?

CathyS_Slalom_1-1654638229085.png

 

CathyS_Slalom_0-1654637926086.png

 

binuacs
20 - Arcturus

@spuri5 as @CathyS_Slalom said the regex formula works based on your given input file and its works for me. Can you provide the input file which you are trying with the formula? output as per your given input

 

binuacs_0-1654668821052.png

 

spuri5
7 - Meteor

Hi @CathyS_Slalom and @binuacs ,

 

Sorry for the confusion, Please find attached the actual sample Input file.

 

Expected output as shown below:

 

spuri5_0-1654696803968.png

 

Labels