Formulas: logical function AND/OR not working as expected

Hi!
I’m quite new to Baserow but have 15+ years of experience with dabases and an extensive experience with other no-code database solutions.

I’m trying to do something fairly basic in a formula field: use a series of and/or conditions to determine the value of a status field.
The problem is, AND and OR functions are limited to 2 arguments, which is quite unexpected and forces to add up many AND/OR operators. This renders formulas quite heavy and very hard to read.

Example with a very simple set of AND conditions:

  • instead of:
AND(
  totext(field('Status'))="Validated",
  field('Name')!="",
  field('Description')!="",
  totext(field('Language'))!="",
  field('Rank')>0
)
  • we need to write:
AND(
  totext(field('Status'))="Validated",
    AND(field('Name')!="",
      AND(field('Description')!="",
        AND(totext(field('Language'))!="",
        field('Rank')>0
))))

Is there a plan to support more than 2 arguments to AND and OR functions in the future and avoid impossible formulas with dozens of operators?

Best,
Ludo

100% agree that the AND/OR formulas and probably some other functions should work as you have proposed. CONCAT already works this way with a variable number of arguments so it’s very possible for the language to technically support this. Will open a feature request to track this.

Separate thought here, we could also add && (AND) and || (OR) operators to the language which in addition to a better and function. So you could write true && false && false = false etc

I’ve got the same problem.
But somehow the formula with && doesn’t work neither …

Bildschirmfoto 2023-12-01 um 06.24.51

Hey @Martin,

Currently, our AND and OR formulas don’t support more than two arguments. As Ludom mentioned in the first comment, we need to write them in a nested way:

AND(
  totext(field('Status'))="Validated",
  AND(field('Name')!="",
    AND(field('Description')!="",
      AND(totext(field('Language'))!="",
      field('Rank')>0
  )))
)

I’ve logged this issue here: Add `&&` and `||` operators in formula language (#2135) · Issues · Baserow / baserow · GitLab.
While I can’t promise a specific timeline for addressing this, I’ll discuss it with the team.
Thanks for your feedback.

Hello @davide ,
Have you been able to discuss that with the product team? Is it sth that could be considered in one of the roadmap milestones?
Best,
Ludo

Hello @Ludom,

I’ve created a MR with the changes here Add && and || operators to the formula language.

The changes need to be reviewed and tested, but there’s a high chance we can include them in the next release.

Hi Davide,
Thank you very much, this looks great!
Just one thing: does that mean that we’ll be able to combine these in a formula (e.g. bool1 && bool2 && bool3 && bool4…)?

Best,
Ludo

Yes, this will be a valid formula. You’ll need to properly use parentheses when combining the operators, but it’ll be possible to create, let’s say, a long list of && or || without parentheses.

Example of a working formula:
Screenshot 2024-03-26 at 13.35.37