Forum Discussion

NealMathews's avatar
NealMathews
Qrew Trainee
7 years ago

If Statement Help

I'm trying to write a formula to return a numeric value. 
I have 5 numeric fields (Bedroom1, Bedroom2, Bedroom3, etc...) the user will enter in the square footage for each bedroom. 

I then have a field where I would like to calculate the number of bedrooms, but only If the value in each of the Bedroom fields is greater than 50 square feet. 
  • You can use something like this:

    If([Bedroom 1]>49,1,0)+
    If([Bedroom 2]>49,1,0)+
    If([Bedroom 3]>49,1,0)+
    If([Bedroom 4]>49,1,0)
  • JasonJohnson's avatar
    JasonJohnson
    Qrew Assistant Captain
    Or you could learn about variables and do something simple to start with like this. Not that it is really needed here but it helps learn a bit about variables in formulas.

    var number bedone=If([Bedroom1]>49,1,0);
    var number bedtwo=If([Bedroom2]>49,1,0);
    var number bedthree=If([Bedroom3]>49,1,0);
    var number bedfour=If([Bedroom4]>49,1,0);
    var number bedfive=If([Bedroom5]>49,1,0);

    $bedone+$bedtwo+$bedthree+$bedfour+$bedfive