Formula Field variable set in if statement

  • 0
  • 1
  • Question
  • Updated 3 weeks ago
  • Answered
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?
Photo of Ryan Stanford

Ryan Stanford

  • 512 Points 500 badge 2x thumb

Posted 3 weeks ago

  • 0
  • 1
var text variable = Case([Male/Female],"Male","This one is Male","This one is Female");
$variable
Photo of Ryan Stanford

Ryan Stanford

  • 512 Points 500 badge 2x thumb
Of course! I keep forgetting to look into Case Switches!
Photo of Ryan Stanford

Ryan Stanford

  • 512 Points 500 badge 2x thumb
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?
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.
Photo of Ryan Stanford

Ryan Stanford

  • 512 Points 500 badge 2x thumb
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")


That would work too! Just remember the semi-colon at the end of declarative statements.