Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Hello All - Does anyone here know why I would be getting the called for result in instances where there is NO accepted date? (Perhaps relative only to last section of case? Not sure.)

Many thanks for your consideration. JW

Case( ArchiveOverride = 1, "Archived",

ProjectCategoryOverride <> "", ProjectCategoryOverride,

CStatus::Accepted Date <> "", "Post CCA", "Pre CCA",

CStatus::Accepted Date <> "" and AsBsRecdinMFPRUfromDelinDate <> "" and ACStatusNewRev = "On File" and DRSStatusNewRev = "On File", "Archived",

CStatus::Accepted Date <> "" and AsBsRecdinMFPRUfromDelinDate <> "" and (ACStatusNewRev = "Pending" or DRSStatusNewRev = "Pending"), "Pending TIF Upload and/or AC Receipt")

Posted

The Case function evaluates each test in order, and returns the result specified for the first test that evaluates as true.

In your example, the last 2 tests can be true only if the third test is true, so it never gets to them. Change the order of your statements, so that the specific comes before the general.

---

Unrelated: consider using 'not IsEmpty' instead of '<>"".

Posted (edited)

Oh Geez :bang: What an important little rule to forget about! Many thanks!

Also, I'm curious, what is the reasoning behind using 'not IsEmpty' rather than <>""

Edited by Guest
Posted

For one thing, it's more readable.

For another, "" is an empty TEXT string, so strictly speaking a date field is never equal to "". Filemaker is rather relaxed in this aspect, but as it moves towards being a serious database, this might change - so call it future-proofing.

Posted

Hi Julia,

Since you are the curious sort, another idea worth considering is boolean logic, isn't it Michael? I believe it would also be future proof as I expect FM to always embrace boolean. If any of those fields contain number (or date) then ANY numeric value (to FM) will produce true (dates are numbers also). Field type can be text, number or date but MUST contain a number (or 0 or be empty) for boolean to translate * properly.

Example, assuming those Override fields contain a 1 (for yes):

Case( ArchiveOverride , "Archived" ,

... will work same as ...

Case ( not IsEmpty ( ArchiveOverride ) , "Archived" ,

So you calc might also look like this (note dates are listed without a test also):

Case ( ArchiveOverride , "Archived" ,

ProjectCategoryOverride , ProjectCategoryOverride ,

AcceptedDate and AsBsRecdinMFPRUfromDelinDate and ACStatusNewRev = "On File" and DRSStatusNewRev = "On File" , "Archived" ,

AcceptedDate and AsBsRecdinMFPRUfromDelinDate and ( ACStatusNewRev = "Pending" or DRSStatusNewRev = "Pending" ) , "Pending TIF Upload and/or AC Receipt" ,

AcceptedDate , "Post CCA" , "Pre CCA" )

* Certain text entries (in versions prior 7) will also return boolean true result (Y, N, Yes, No, T, F, True, False) but I suggest you steer clear of using them in this way. Since your test simply determines whether the fields are empty then these exceptions wouldn't apply anyway.

I believe boolean logic is a bit quicker (and to me it is MUCH clearer) so if you are comfortable it might be used here as well. It is easy to remember that a number (or a date) IS or it ISN'T. Even if you don't use it here, boolean logic is a powerful concept which should be taken advantage of whenever possible.

LaRetta :wink2:

Posted

Case( ArchiveOverride , "Archived" ,

... will work same as ...

Case ( not IsEmpty ( ArchiveOverride ) , "Archived" ,

This wouldn't work for me, since I often have a value of 0 in the field. So either:

Case( ArchiveOverride , "Archived" )

or:

Case( not ArchiveOverride , "Active" )

Posted

I'm going to jump in here with something of a tangent: I am not a big fan of using the Case statement to make comparisons in different fields. It is very easy for the circumstances in the separate fields to fail to be both mutually exclusive AND completely exhaustive. This is a good example of that difficulty.

Nested If statements can get quirky very quickly, but I find I am a more reliable programmer when I use them. They force me to be sure that each eventuality is clearly accounted for. (I was going to try to do this calculation as a nested If, but the last two tests made my brain hurt).

David

Posted

This is a good example of that difficulty.

Hi David, :wink2:

I think you might be misinterpreting here...

Case() is quite valid for all comparisons and works wonderfully in this calc, regardless. Our discussion revolves around the not IsEmpty() test itself which would fail if numeric result is 0 (a boolean test would not fail in either case), pun intended.

I like the clarity of If() because my mind easily understands there are two possible options and Case() offers more than two ... that is the ONLY difference between them (in versions 7/8). In versions less than 7, If() also requires a default result and Case() does not. But I feel nested If()s are more confusing and (I think) also require more cycles to process. Miss one proper default result on an If() test and the calc will fail just as easily. Case() is the winner if more than two results are required. That is its purpose after all ...

But, as with all things in FM, there are many ways to write a calculation. :smile2:

LaRetta

Posted

I think what you're saying, IOW, is that using Case() requires you to think out all possibilities in advance. And to test thoroughly. That, IMHO, is GOOD thing. A VERY good thing. And it applies to ALL calculations (and scripts, and relationships...), not just the Case() function.

This topic is 6969 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.