Using Checkbox to Apply Filters

I have a table with a “Status” selection box column; this has predefined values such as “Draft”, “Published” and “Archived”.

I want to be able to allow users to filter the table based on “Status”, but so that any combination can be selected. Currently, we’re achieving this using a Multiselect Control, but I’ve had requests to change this to checkboxes; there’s a few reasons why this fits better, but the big one is that instead of it saying “Draft + 2” (for example), it gives immediate visibility on which “Status” options are being filtered for right now.

However, I currently cannot get this to work. I can do it for a single value, but not multiple checkboxes being selected. I’ve tried using formula elsewhere that produces a string of “Status = ‘Draft’ AND Status = ‘Archived’” and referenced that, but it doesn’t work.

Is there anyway to set the value of a multiselect dynamically? If so, I could definitely patch something together. If not, any suggestions on how this might work?

FYI the checkboxes are not contained within the table.

1 Like

@Murray_Adcock

I was just refactoring mine. This probably isn’t what you want, but I place on the canvas beneath the multiselect control a formula outputting the multiselect value to a bulleted list, so that I can quickly see what is selected:

I can’t wait until these filter controls are built into the table interface. :innocent:

1 Like

Nevermind, I just solved it :laughing: But thanks @Ander, interesting method :slight_smile:

For anyone else trying to do this the trick is the .Contains() function.

I set up my checkboxes with names like “filterArchived”, “filterDraft”, “filterSubmitted” etc.

I then filtered my table with the following formula:

[Status].Contains(If([filterArchived],"Archived",""),If([filterDraft],"Draft",""),If([filterSubmitted],"Submitted",""))

What this does is check each checkbox by name within the .If() statements, and if it returns true (i.e. is checked) then adds the related Status value to the array being queried within .Contains(), if it returns false it just leaves the addition blank.

If they’re all unchecked, you get a string filtering on blank, so it displays any rows without a Status, but I can live with that (as there shouldn’t be any really) :slight_smile:

1 Like

Was working on and had the same solution so sharing the doc here in case anyone in the future wants to copy and play with it.

2 Likes

@Murray_Adcock

That’s funny, I was just solving for this (couldn’t live with it in my case). I appended a second OR statement to my filter for the case when all the checkboxes are unchecked. It works, but adds significant length to the filter formula.

1 Like

hi all coda noob here: Anyone have advice on how to make this work when referencing a lookup column? Love this approach and have tried to recreate it exactly but can’t seem to get it to work… and not getting any specific “errors” per se so it’s tough to trouble shoot. The only difference i can identify vs. @mallika’s example is that i’m looking at a lookup column vs a text column… formula below.

thisRow.Status.Contains(if([5876PaidToggle 2],"Paid","None" ), If([5876UnpaidToggle 2],"Unpaid","None"))

**edit after pasting my formula: the use of “thisrow” seems incorrect but when i simply try to input the column name, it autocompletes to that!

Without seeing your doc it is hard to tell but as you mentioned Lookup I’d recommend you try entering Paid as @paid and selecting from the options provided. If it is a lookup value it won’t be a string “Paid” but will need to be reference ( same type as lookup). If you share your doc here or via support@coda.io I can take a quick look.

1 Like

THAT was it! thank you so much! totally forgot about the importance of “@” :slight_smile: thank you-

2 Likes

It would be really nice to instead make the multiple-select control more flexible to format (e.g., wider).

And even better, I’d like to be able to create a filter control that renders multiple checkboxes based on available values. The multi-select dropdown can be awkward to use, requiring a lot of clicks to 1) open, 2) select item, 3) close.

@Ander
How did you output the multiselect value to a bulleted list?
Thanks

@admin_l

I use this simple setup with most canvas multiselect controls:

@Ander
Thanks - that got me working.

1 Like