Skip to main content
Question

Formula Field variable set in if statement

  • October 26, 2018
  • 0 replies
  • 282 views

What I'm trying to do is have a variable that is declared in a formula field, and that variable equals one of two fields, depending on an if statement.

for example:
---------------------------------------------------------------------------------------------------------------------
var Text variable = "";
If([Male/Female] = "Male", variable = "This one is Male";,variable = "This one is Female";)

$variable
----------------------------------------------------------------------------------------------------------------------

This is a simplified version, which focuses on my question. I can't have this field to just be the if statement.

How can I do this in Quickbase?

  • Registered
  • October 26, 2018
var text variable = Case([Male/Female],"Male","This one is Male","This one is Female");
$variable

  • Author
  • Registered
  • October 26, 2018
The case is strictly if the variable = value right? The issue I'm looking to solve is based on the date in a field, or day of the month... I would have to declare each value right?

I would have to do 1 = true, 2 = true, 3 = false... instead of being able to do case variable < 3 = true?

  • Registered
  • October 26, 2018
I used the case statement as it seemed appropriate for the situation. In other situations, you have to use whatever is more appropriate. it depends on the case at hand.

  • Author
  • Registered
  • October 26, 2018
I figured it out... what I can do is use the if statement in setting the variable, like what you did with Case:


var Text variable = If([Male/Female] = "Male", "This one is Male","This one is Female")



  • Registered
  • October 26, 2018
That would work too! Just remember the semi-colon at the end of declarative statements.