Forum Discussion
- ChrisChrisQrew Assistant Captain
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?
- JimHarrisonQrew ChampionBut we are not using a field called , otherwise your response would make sense and is covered in the reference.
- ChrisChrisQrew Assistant CaptainSo, 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".
- JimHarrisonQrew ChampionSo 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)
- QuickBaseCoachDQrew Captainimho 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. - ChrisChrisQrew Assistant CaptainYeah, 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().
- QuickBaseCoachDQrew CaptainGood 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.
- JimHarrisonQrew ChampionIt 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 checkedCase(
[cxbx1]=[cxbx2],
true,
[cxbx3]=true,
true,
false
)
always checked except if cxbx1 or cxbx2 checked aloneCase(true,
[cxbx1]=[cxbx2], //this is true
true,
[cxbx3]=true,
true,
false
)