Filtering problem, probably easy fix

I’m not figuring out the best way to do this.

I have a table with a column called “Finished” and the field will either be blank, or it will contain the date that I finished. It came from a 3rd party imported template so that’s just the way they designed it.

In another view, there is a set of filtering dropdowns for various columns attached to the table so that I can do multi-select filtering. The one for “Finished” is True and False, as in, “Is if finished, yes or no”.

If they select both true and false, then it should show all rows. If they select neither, it should also show all rows. Only if they choose either true or false should it filter to the empty cells or dated cells.

My problem is in the filter logic. I assume that an if() function is what I need:

if(finishFilter.ContainsOnly(true), thisRow.[Date Finished].IsNotBlank(), if(finishFilter.ContainsOnly(false), thisRow.[Date Finished].IsBlank(), {WHAT DO I PUT HERE???}))

The if() function doesn’t allow you to not have the “else” block, so I’m not sure what to put for that spot. Or if I’m really using the correct function at all.

How would I essentially make the ‘else’ statement say “then show anything” or “show all”?
When I look at the operators, there isn’t one for a “show anything”. It’s greater than or less than and equals or not equals or is blank or not blank etc. But what would be “can be any value”?

I know the answer is easy but I haven’t tried to code anything in Coda for a while so it’s not clicking how best to do this filter. Because “true” and “false” doesn’t relate directly to “empty cell” and “has a date”.
I know I’ll smack myself as soon as one of you tells me the obvious answer to make this filter work easier.

I just want them to select false for empty cells and true for cells with a date, or both or none to see everything and not filter it.

Hi @Guyinpv! If the task is to write a filtering formula specifically for a “Select List” with three states, you can do it like this:

SwitchIf(
  finishFilter.ContainsOnly("true"), thisRow.[Date Finished].IsNotBlank(),
  finishFilter.ContainsOnly("false"), thisRow.[Date Finished].IsBlank(),
  true, true
)

If you’re just using a binary toggle, you can do it like this:

If(finishFilter2, thisRow.[Date Finished].IsBlank(), thisRow.[Date Finished] or thisRow.[Date Finished].IsBlank())

When turned off, the filter shows everything, and when turned on, it shows only values with an empty date.

To make sure I understood you correctly, I’m attaching a demonstration doc. :point_down:

Thanks a bunch!

What I was missing is the use of “true, true” or basically just putting “true” as my “else” condition. I guess putting true there is the same as saying “go on as usual” and allows the row to be visible.

In other words, rather than say ‘true’, I was trying to explicitly tell the table to show “anything” like thisRow.[Date Finished].showAll() or any() or whatever. But it simply had to be true.

Another interesting thing I learned is when copying the formula into the forum here, it exposes the thisRow object, which I don’t see in Coda itself. For some reason I didn’t realize the formula was being performed like a loop at the row level. In my head the formula was working on the whole table as a single entity at once, rather than as a loop over each row. That makes sense then because true just means the row can be allowed to show. While true applied on the table as whole wouldn’t have made sense in my mind before.

1 Like

Yes, you were very close to solving it! You can even simplify it by keeping just one “true.” In cases of multiple selections, when none of the specified conditions are met, the formula defaults to “true,” ensuring that all rows are included.

Specifically for the if() function, it did not have a default “else”. The formula would throw an error if I left that off. So just putting true there does the trick.

2 Likes

When you wish to leave the ‘else’ part undefined, you should use the SwitchIf() alternative. It does not require the dangling else to be defined.

With the If() formula, returning True is one way, but we normally return a blank using "" as being a better representation of a null result. but that’s just a convention.

In other words. it does not have to be the True constant, you could have used False, or 0, any value.

2 Likes

Ah, good to know. Thanks!

I have not tried to educate myself too deeply on Coda since I’m still trying to discover if I should go with Coda or Notion or something else.

Tons of videos about using Notion for a business “operating system” and lots of people selling templates and such. I don’t see that as much on Coda, and yet Coda people tend to say it is much more powerful than Notion, so I don’t know.
Once I figure out what I’m going to use, I’ll be learning a lot more.

from my extensive experience guiding companies on both Coda and notion, i have formed an opinion.

those who are comfortable with using formulas to implement complex business logic (eg. have a lot of experience with complex spreadsheets) are better off using Coda, as they can harness its much greater power.

those who do are not comfortable with those more advanced capabilities, tend to be better off with notion. but then they will have to a lot more work manually day to day, because notion has almost no processing abilities in its formula language.

this difference is, imho, the reason for the higher population of users of notion.

but if you are able to exploit the amazing automation features of coda, then you do not need all those pre-built templates and videos… because you will prefer to build your own - and they will match your needs and the needs of your business far better.

just an opinion
max

3 Likes

Good opinion Max, I completely agree.

I would add one other difference: Packs.

They are a benefit in two ways: lots of makers, including Coda, has made and will make packs. To connect with other sites, or to add additional formula, to the formula language.
The second benefit is that if I have a specific need for integration and formula functionality, then I don’t have to wait for Coda to get around to it. I can do it myself, or pay one of a growing group of makers to do it for me.

But it’s just a ramble,
Rambling Pete

1 Like

Good points.
Now I just worry what the Grammarly thing will change. And over stuffing AI. And I can’t share a single page without them seeing other pages on the doc. And inabilities regarding collaboration without requiring login.

I stopped using Notion a few years ago, but back then privacy options were even more limited than Coda’s and since then Coda has made some progress. AI stuffing I believe is similar?

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