Jump to content
Sign in to follow this  
MariaAux

Nested IF Logic

Recommended Posts

I'm Web publishing a Database of children's games. There are 4 fields;

Preparation (sometimes empty)

How_to_Play (Always filled)

Variations (sometimes empty)

Notes (sometimes empty)

I am trying to create a nested IF function that only displays the field if it has some text in it. Just displaying one big blob of text listing field after field is obviously easy, but I want to add a header above each field if the field I included. I am getting stuck because the 1st, 3rd and 4th field are all variables. This is as far as I've got;

If (Preparation=0;"";"PREPARATION"&¶&How_to_Play)

Up until here is fine, but now adding the IF function if Variations or Notes are also empty by including/excluding them or their headers is getting me a little stuck. Any help would be HUGELY appreciated.

Thanks so much in advance,

Share this post


Link to post
Share on other sites

If (not isempty ( Preparation); "Preparation¶" & Preparation & ¶¶; "") & If (not isempty (How_to_Play); "How to Play¶" & How_to_Play; "") &

etc.

Share this post


Link to post
Share on other sites

hi bcooney,

I guess you mean the "&" and not the "and" operator :)

otherwise it would evaluate to 0 or 1.

Share this post


Link to post
Share on other sites

My gosh, yes! Need another coffee after yesterday. I've corrected my original post.

Share this post


Link to post
Share on other sites

A few small points - 1) if you use two ¶ together, you must wrap them in quotes as "¶¶" so the above calc will throw a syntax error and 2) it is not necessary to list a default result when using If() or Case() (blank is assumed) so you can drop the "" results:

If ( not IsEmpty ( Preparation ) ; "Preparation¶" & Preparation & "¶¶" )

&

If ( not IsEmpty ( How_to_Play) ; "How To Play¶" & How_to_Play & "¶¶" )

&

If ( not IsEmpty ( Variations ) ; "Variations¶" & Variations & "¶¶" )

&

If ( not IsEmpty ( Notes ) ; "Notes¶" & Notes )

Share this post


Link to post
Share on other sites

You guys are Geniuses! Laretta, your formula was fantastically simple to follow... and worked like a Charm. I don't know if I could really convey my absolute gratitude - You made my day! Have a wonderful day and thank you thank you again!

Share this post


Link to post
Share on other sites

LaRetta, you're so much more thorough than I am. I need to step it up.

Share this post


Link to post
Share on other sites

Hmmm . . . I've always learned from both of you!

RW

Share this post


Link to post
Share on other sites

And so do I, Rick. An error in one post does not a failure make. If so, I would be lower than the ground that dirt sits on. :yep:

Share this post


Link to post
Share on other sites

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

Sign in to follow this  

  • Similar Content

    • By dysong3
       
      Hi,
      Here is a custom function that I found on Briandunning.com.  The problem is when I try to create a new function with this code, Filemaker refuses it saying 
      The "here" above is situated before the parentheses after "WordWrap" and before "UnprocessedText".  Would someone be kind enough to tell what I'm missing here to get this up and running?
      Let ([ TruncatedText = Left ( Text ; Size + 1 ) ; CountOfSpaces = PatternCount ( TruncatedText ; " " ) ; CountOfReturns = PatternCount ( TruncatedText ; "¶" ) ; PositionOfLastSpace = If ( CountOfReturns > 0 ; Position ( TruncatedText ; "¶" ; 1 ; 1 ) ; Position ( TruncatedText ; " " ; 1 ; CountOfSpaces ) ); AddReturn = If ( CountOfReturns > 0 ; "" ; " ¶" ); ThisLine = Trim ( Left ( TruncatedText ; PositionOfLastSpace ) ) ; UnprocessedText = Right ( Text ; Length ( Text ) - PositionOfLastSpace ) ; Result = If ( Length ( Text ) ≤ Size ; Text; ThisLine & AddReturn & WordWrap ( UnprocessedText ; Size ) ) ]; Result ) Sorry everyone.  Please dismiss my post.  I just realised that I was trying to include "WordWrap" as a function parameter and as the function name.  All's well.
    • By dougroth
      I'm a dentist. I'm trying to generate written treatment plans for patients to have as a treatment estimate and for our records.
      People have 32 teeth, therefore I have setup a field (ToothNumber), displayed as a checkbox set utilizing a value list = 1 through 32. When I click my CROWN script button, it opens a selection window wherein I choose the tooth number from said field (1-32), the material the crown is to be made of (porcelain, gold, zirconia, etc.), whether I want to use lab-processed temporary crowns, and so forth. 
      If I have only one tooth number checked and run through my nested IF statements, which looks up the official description for the type of crown, the ADA code, the fee, the time required, etc., it all works fine. If I have more than one tooth number selected in the checkbox set, it only returns one line for the first tooth checked. 
      The IF statement looks something like: If TOOTH NUMBER = 2 and CROWN MATERIAL = porcelain and LAB TEMP CROWN = "Yes" then it adds a line on the treatment items table which looks up appropriate description, ADA code and fee, so the patient has a copy and so do we. And we're both on the same page regarding what they want to accomplish. 
      Am I using the wrong method for displaying and relating my selections? If so, what's the best way to accomplish this. Also, I want to avoid repeating the same sequence for each tooth number, i.e., I'd rather LOOP to advance through tooth 1 through 32. Any ideas? 
    • By Kurt Hansen
      I have a calculated field that is based on the following. Now I want to add this:
       
              If ( LABEL = "Eloquence" ;
                      Case (
                          ANTAL I ALBUM = 1 ; "79,50" ;
                          ANTAL I ALBUM = 2 ; "149,50" ;
                          ANTAL I ALBUM = 3 ; "219,50" ;
                          ANTAL I ALBUM = 4 ; "219,50" ;
                      "Mangler kalk");
      Where and how do I put it in? I have tried almost everything, but I keep getting error messages.
      --- Current definition ---
      If ( GENRE = "Klassisk" or GENRE = "Jul" or GENRE = "Jazz" or GENRE = "Pop / Rock" or GENRE = "Soundtrack" or GENRE = "Traditional" or GENRE = "Tale" or GENRE = "Film";
              If ( LABEL = "Brilliant" ;
                      Case (
                      NORMALPRIS = 34 ; "49,50" ;
                      VARENUMMER = 94137 ; "169,50" ;
                     "Mangler kalk");
              Case (
              Left ( VARENUMMER  ; 5  ) = "GRAM," ; "70,00" ;
                    VARENUMMER =  "CCS BOX 6414"; "349,50" ;
                    VARENUMMER =  "AV 2313"; "799,50" ;
              NORMALPRIS = 11 ; "29,50" ;
              "Faktor?")
          ) ;
      "---" )
    • By kathrynfw
      I am trying to create a field that will generate a list of phrases according to a criteria. It is based on input from a questionnaire, and designed to pull up the phrase whenever the answer to the corresponding field was higher than a one. Even though I set all the questions to two or three, the only one that is working here is the first one. In the merge field, it should list all of the phrases in quotes, but it only gives me "functional math." Can anyone see what is going on here? I am self-taught and really a novice on the calculation side of things.
      Thanks so much.
       
      If (Functional math deficits >=1; "functional math”,If (Functional reading deficits >=1; "functional reading”,If (Functional written language deficits >=1; "functional written language”,If (Impaired Theory of Mind >= 1; "theory of mind”,If (Difficulty reading social cues >=1; "social skills”,If (Difficulty sitting  attending >= 1; "learning behaviors”,If (Lacks functional living skills >= 1; "functional living skills”,If (Lacks functional play skills >= 1; "play skills”,If (Lacks independent leisure skills >= 1; "independent leisure”,If (Is over 14 lacking vocational skills >= 1; "vocational skills”,If (Student has challenges with expressive language >= 1; "expressive language”,If (Student has significant delays in receptive language >= 1; "receptive language”,If (Gross motor deficits >= 1; "gross motor skills”,If (Fine motor deficits >= 1; "fine motor skills”,If (Need for schedule >= 7; "use of visual schedule”,If (Need for work systems >=7; "using work systems and task strips for independent routines”))))))))))))))))
       
      I am not getting any errors when I save the calculation parameters (Probably not the right lingo...)
       
    • By rick altman
      I have a field that receives a bunch of first names from a portal, thanks to the List function. The result might look like this:
       
      Alice, Bill, Chuck
       
      However, I need for the list to read:
       
      Alice, Bill, and Chuck
       
       
      I need to find the last comma in the text and add an "and" to it. I have been messing around with the Position function stuffed inside of a Substitute function, but I can't get it right. Can someone help?
       
      FMPA14
       
       
      Rick A.
      Pleasanton CA
×

Important Information

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