Sign in to follow this  
Followers 0

Nested IF Logic


10 posts in this topic

Posted

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,

0

Share this post


Link to post
Share on other sites

Posted

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

etc.

0

Share this post


Link to post
Share on other sites

Posted

hi bcooney,

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

otherwise it would evaluate to 0 or 1.

0

Share this post


Link to post
Share on other sites

Posted

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

0

Share this post


Link to post
Share on other sites

Posted

probably the right brain kicking in :)

0

Share this post


Link to post
Share on other sites

Posted

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 )

0

Share this post


Link to post
Share on other sites

Posted

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!

0

Share this post


Link to post
Share on other sites

Posted

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

0

Share this post


Link to post
Share on other sites

Posted

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

RW

0

Share this post


Link to post
Share on other sites

Posted

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:

0

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  
Followers 0