What does the true value mean at the beginning of some case statements in QuickBase?

  • 0
  • 1
  • Question
  • Updated 11 months ago
  • In Progress
I looked at the Formula reference and through the community and don't see an explanation to this syntax. 

I can see other language references on Google but want to get specific documentation.

Can anyone tell me the purpose of the true at the beginning of some case statements.

Example Case(true, eval1, true, eval2,true,false)

Is this setting the default value of the field as true? Or is it only evaluating the eval1 statement if the value in the field is true.
Photo of Jim Harrison

Jim Harrison

  • 1,768 Points 1k badge 2x thumb

Posted 11 months ago

  • 0
  • 1
Photo of Chris

Chris, Champion

  • 4,390 Points 4k badge 2x thumb

Let's take a field called [Verify], it is of type formula text. Below is its code.

Case(

[value],1,"OK",2,"OK",3,"Bad",4,"Worse"

)


So what we've done in [Verify] is make its text value either "OK", or "Bad" Or "Worse", depending on the value of [value], when [value] is 1 or 2 or 3 or 4.

If 1 is true, then "OK". IF 2 is true, then "OK", if 3 is true, then "Bad", if 4 is true, then "Worse".

Does this make sense?


(Edited)
Photo of Jim Harrison

Jim Harrison

  • 1,768 Points 1k badge 2x thumb
But we are not using a field called [true], otherwise your response would make sense and is covered in the reference. 
Photo of Chris

Chris, Champion

  • 4,390 Points 4k badge 2x thumb
So, as we evaluate [Value], we are asking, is [value] equal to 1? If it is equal to 1, then that logically equates to boolean true. Since it is true ( in this explanation ) that [Value] is equal to 1, then the formula text field [Verify] will be equal to "OK".
(Edited)
Photo of Jim Harrison

Jim Harrison

  • 1,768 Points 1k badge 2x thumb
So the first "true" is referring to the current value of the formula. The field where the case statement formula is stored.

Given it is a checkbox field then where 2,3,4 are other fields being evaluated.
Case(true, true,[2],true,[3],true,[4],true,false)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
imho it works but is a confusing syntax to use,

The results is the same as this

IF(
eval1=true, true,
eval2 = true,true)

but that can be simplied to

IF(
eval1, true,
eval2,true)


In this case both eval 1 and eval true are boolean checkbox formula fields.
Photo of Chris

Chris, Champion

  • 4,390 Points 4k badge 2x thumb
Yeah, but If() is for more complex logical constructs. Case() is great to evaluate one variable of limited possible values. The logic probably executes faster than IF().
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Good luck with a stop watch to try to measure any difference.  Evaluating TRUE against two expressions for eval1 and eval2, is the same as calculating the TRUE or not of those two expressions.  either way Quick Base has to calculate if they are each true.
Photo of Jim Harrison

Jim Harrison

  • 1,768 Points 1k badge 2x thumb
It appears to set the default value for the field. 

Made a table with some fields and here is the result. 
always unchecked except if all or cxbx3 checked

Case(

[cxbx1]=[cxbx2],

true,

[cxbx3]=true,

true,

false

)

always checked except if cxbx1 or cxbx2 checked alone

Case(true,

[cxbx1]=[cxbx2], //this is true

true,

[cxbx3]=true,

true,

false

)