How to use a Toggle to filter a view


I have a table of tasks. The table has a priority column. I would to the the Toggle control to filter the table. So when the Toggle is on, the table only displays tasks with a priority of P0 for example.

There is another post on this, but in all honesty, I’m not getting it.

Can anyone help :slight_smile:


Sure thing. It can be a bit weird to get your head around, because there are kind of 2 layers of “True/False”.

A simple filter, that would show only P0 all the time, would be:
Priority = P0

As Coda examined each row, it would ask if the expression “Priority = P0” resulted in “True” or “False”. Keep in mind that filter expressions keep rows that result in “True”, and discard rows that result in “False”

So how do we take this further? In plain English, we want to keep a row if

  • if the toggle is switched on, then only keep rows where Priority = P0
  • otherwise, if it’s switched off, keep everything

So here we go:

  /* If what? If my toggle, which I called ShowOnlyP0Toggle, is turned on */
  ShowOnlyP0Toggle = True,
  /* Ok now tell Coda what to do if the toggle is switched on. */
  /* In this case, we want to apply our original filter of Priority = P0 */
  Priority = P0, 
  /* Otherwise (i.e. if the toggle is NOT switched on), just always  */
  /* result in "True", which is our way of keeping all rows */

The main trick here is that “True” line. Basically, you can use “True” and “False” in filters as a way to just explicitly say “keep the row” or “discard the row”.

Does that make sense?

P.S. enclosing text in /* and */ is a new “code commenting” feature from Coda. Coda will ignore anything inside those, so you can leave notes for future you.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.