Having trouble with a formula

Hello again Friends,
I am having trouble with a formula. I am trying to make a text display formula. I have a First Name, Last Name, Spouse Name data fields. If there is no spouse then it would display " Harry Fields". if there is a spouse I would want it to display “Harry Fields (Judith)”. The problem I am having is if there if the Spouse Name field has something in it I want to include the opening and closing parenthesis in the display. Any ideas would be appreciated. I just need a conditional statement that IF there is something in the Spouse Name field it will include the parenthesis.

The formula you list would not have worked the way you want in Panorama 6. Fortunately, the answer is easy, and this will work in both Panorama 6 and X.

«First Name»+" "+«Last Name»+sandwich(" (",«Spouse Name»,")")

The sandwich( function is one of my favorites – I use it ALL the time for applications just like this.

Thanks Jim,
I should have known that. I have used the sandwich before. My old Panorama handbook is falling apart and getting harder to find things without the pages falling out. Thanks again Jim and Thanksgiving Blessings.

1 Like

I think you don’t want to have an empty set of parentheses, when your field Spouse Name is empty. So I would try a formula like this:
«First Name»+" "+«Last Name»+?(length(«Spouse Name»)>0,sandwich(" (",«Spouse Name»,")"),"")

P.S.: OK, i see in the documentation that the sandwich function already takes care of empty fields. So Jim’s formula is fully sufficient.

Sandwich takes care of the empty Spouse and only ‘sandwiches’ the parentheses when there is ‘meat’ (spouse info).

Robert Ameeti
(949) 422-6866