Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Single Formula expression to retrieve comma-separated values from a List Box

Scott_Snowman
10 - Fireball

I am attempting to use a List Box to generate a comma-separated list of values that have been selected. That part is easy enough

 

  1. Use the results of the List Box selection to update a Text Input tool
  2. Split the cell to rows with a comma delimiter
  3. Filter to rows that contain "=True"
  4. Use a Formula to remove the "=True" strings from the values
  5. Summarize with the Concatenate option to get a comma-separated list of checked values.

See example screen shot. As expected, the output of the final node is 'parameter1,parameter3,parameter4'

 

ScottS28_0-1571894878748.png

 

However -- is there a way to do this in a single Formula expression? (It'd have to involve RegEx, I'm sure.)

 

My goal is to use the comma-separated list in combination with the Action Tool's "Update Value with Formula" option to directly supply the comma-separated list to another tool in the macro.

3 REPLIES 3
lmorrell
11 - Bolide

Hi @Scott_Snowman,

 

replace(regex_replace([A], '(\,)*\w*?=False(\,)*', ''), '=True', '')

This formula replaces all the values that equal false using regex, and then replace the '=True' string with a regular replace. 

 

Hope this helps neaten up the workflow!

 

Scott_Snowman
10 - Fireball

@lmorrell truly, it should be said that with a long enough RegEx expression and a place to stand, one can move the world. (Or, perhaps at least replace it with something more desirable.)

 

I definitely need to study more RegEx. Thank you so much!

 

That being said this looks just slightly off. I get the following with a test string:

 

parameter1=True,parameter2=True,parameter3=False,parameter4=True
parameter1,parameter2parameter4

 

The comma before the final parameter always seems to be missing and my attempts to fix it weren't successful.

 

Any ideas?

 

Edit: By changing the provided RegEx to the below, I'm left with what I need but a trailing comma at the end if I have any True parameters before any False parameters. That's easily Trimmed away.

 

\w*?=False(\,)*

 

So this looks like it should work:

 

TrimRight(replace(regex_replace([A], '\w*?=False(\,)*', ''), '=True', ''),',')

 

Scott_Snowman
10 - Fireball

@lmorrell if my edited solution makes sense, and you would like to adjust your original response to include, I'll gladly mark it as the Solution.

 

Thank you!!

Labels