Jump to content

if statement


This topic is 8620 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I have a field define as a calculation type.

I want to create a nested if.

Ex. If(mother="deceased")and

If(father="deceased")

field="the late "

New to filemaker pro.. Not sure of the syntax. Thanks for your help...

Link to comment
Share on other sites

Assuming you want the words "the late" to appear if both parents are deceased, otherwise the field is blank:

Field=

If(mother="deceased", If(father="deceased", "the late", ""), "")

The syntax is: If(condition, then, else). In this case, there's a nested "If" statement in the "then" part of the first "If" statement.

HTH,

Dan

Link to comment
Share on other sites

quote:

Originally posted by oshnic:

I have a field define as a calculation type.

I want to create a nested if.

Ex. If(mother="deceased")and

If(father="deceased")

field="the late "

New to filemaker pro.. Not sure of the syntax. Thanks for your help...

For this particular instance, you don't need to nest the Ifs. You could do the following:

If( mother="deceased" and father="deceased", field="the late ", "" )

If there does come a time when a nested if would be what you want because you can't get what you need with the above kind of calc, you might want to take a look at the Case statement, which has syntax like this:

Case( test1, result1, test2, result2, default result)

The above is functionally equivelant to

If( test1, result1, If( test 2, result 2, default result ))

But you can see that if you have ten possibilities, a nested If can get pretty convoluted, which is why in general, the Case statement is prefered.

Chuck

Link to comment
Share on other sites

I second that one, Chuck. I find myself using more and more Case statements almost to the exclusion of using the IF() statement. When written:

Case(

test1, result1,

test2, result2,

test3, result3,

default)

it is much easier to create, read, and debug. The added carriage returns and blanks cause no problems. -bd

Link to comment
Share on other sites

This topic is 8620 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.