Launched: Set control value action

Hi John! I’m afraid it’s been quite some time since I set this up and am not even sure in which doc I did so anymore :slightly_frowning_face: So, apologies in advance if I’m not fully remembering the scenario correctly, but I spun up another doc to walk thru this :slight_smile:

Also, this functionality has improved in the past year or so, so hopefully this is even better!

Let’s say I have a table of foods, and each food can be assigned a Type like protein, vegetable, or fruit.

The first thing I’ll do is make sure my Type column is a select list, so that the only values in it can be the types I indicate above.

After clicking “New,” I’ll let the Coda magic pre-fill the selectable items based on what I have in the table already. (I could also type in new values, or use a table, but for simple use cases, I like this way.)

Why do I want a select list? Partly for data validation, and partly to have the type of control I want to filter my data.

So, next I’ll create an interactive filter on my Type column to allow me to filter based on selectable types of food:

By default, this will give me a select list control above my table. You can always click and drag it to a new location if desired, but above the table tends to be a convenient spot for it!

Here’s an example of me using the new control to filter my results only to Proteins:

Now I want to create a “Reset” button. To do so, I’ll type /set control value in the location on the canvas where I want to put my button, and choose that button type. Then, I’ll fill in my button settings:

  • A memorable name & label
  • Confirm the action is “Set control value”
  • Select the name of the control (interactive filter) I configured above – in this case it’s “Select Foodstuffs Type”
  • Set my value as listcombine(Foodstuffs.Type.Unique(),"")

So what the hanky is that formula?

Basically the syntax is: ListCombine([Name of the Table].[Column with the possible values].Unique(), " ")

What I’m telling Coda with that formula is:

  1. Look at this table
  2. Select a combination that includes (1.) the list of all of the unique values from the “Type” column, and (2.) blanks (aka " ")

^ Note, you can get away without the unique() part of the formula, but I find it’s a good habit to build as your tables get bigger and more powerful to optimize for performance by telling Coda: “Please only worry about the unique possible values, and not the values in each and every row of the table.”

Et voilá! Because this is a formula in a “Set Control Value” button type, it will set the control (aka, interactive filter) to all of the possible individually-selectable values–including blanks.

Screen Capture on 2022-03-09 at 20-10-21