添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
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:
  • totext(field('Status'))="Validated", field('Name')!="", field('Description')!="", totext(field('Language'))!="", field('Rank')>0
  • we need to write:
  • 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,

    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:

    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,

    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,

    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:

    Hi @davide !
    Since the last BaseRow release, I’ve tried using the && syntax but got the following type of error message every time:

    Error with formula: argument number 2 given to operator && was of type number but the only usable type for this argument is boolean, argument number 2 given to operator > was of type number but there are no possible types usable here.

    Here’s an example of formula that failed:
    field('BooleanField1') && field('NumberField2')>0

    I’ve tried this with a many different field types but got the same result. For instance:
    field('BooleanField1') && field('SingleLineTextField2')!=""
    gives an error message saying the 2nd argument is of type text - whereas it clearly is a boolean expression (I checked its validity by using a formula with only 1 term and it did return a boolean value).

    Using parentheses like this:
    field('BooleanField1') && (field('SingleLineTextField2')!="")
    doesn’t change anything.

    Could you help me here?

    Hi @davide !
    As mentioned above, I tried using parentheses and that did not work either.
    From what I understand, the problem is that this syntax only works together with the if() function which is not the expected behavior.

    As a matter of fact, the only way to make my expression work is to put it like that:
    IF(field('BooleanField1') && (field('SingleLineTextField2')!=""), true, false)

    Which means more complexity for no reason. It also means that these expressions won’t be usable with other functions unless combined with IF([BooleanExpression], true, false) - that is highly unusual and will surely be confusing for most users.

    Best,

    @Ludom can you share a bit more about your fields and your formula?

    As you can see in the pictures below, a formula like field('BooleanField1') && (field('SingleLineTextField2')!="") should correctly create a boolean formula field without the need of an if


    Thank you @davide !
    I’m surprised: the exact same formula I had tried (which generated the error message reported above) worked well today (I merely copy-pasted it again). Maybe there was an update in the latest BaseRow version?

    Best,
    not(isblank(field('Prefix'))), and(field('Messaging Language') = "German", field('Gender') = "m")), concat("Herr",totext(field('Prefix'))), not(isblank(field('Prefix'))), and(field('Messaging Language') = "German", field('Gender') = "f")), concat("Frau",totext(field('Prefix'))), "CHECK GENDER AND LANGUAGE"))

    This is only the very first part of a complex formula we have used for years sucessfully in Google Sheets / MS Excel.

    I tried what feels like a 100 different versions.