6 Replies Latest reply on Apr 5, 2013 6:24 PM by Katie

# Calculation for Shortening Middle Name to First Letter

### Title

Calculation for Shortening Middle Name to First Letter

### Post

I know how to combine First, Middle and Last name fields into one field using a calculation, but is there a way to input only the first initial of the person's middle name (even if there is a full middle name in the middle name field).

For example, if I have the following fields:

First: John

Middle: Joseph

Last: Smith

And I wanted to combine them to read:

"Smith, John J." (instead of "Smith, John Joseph")

How would I do that?  Also, do you recommend using the Trim function in these types of calculations?  Where would I place that?

I have included my calculation for combining the three full names into "First Middle Last" below so you can see what my exact field and table names are.

If ( not IsEmpty ( Contacts::First ) ; Contacts::First & " ") & If ( not IsEmpty ( Contacts::Middle ) ; Contacts::Middle & " " ) & Contacts::Last

• ###### 1. Re: Calculation for Shortening Middle Name to First Letter

Last & ", " & First & If ( Not Isemtpy ( Middle ) ; " " & Left ( MIddle ; 1 ) & "." )

But this will need to be more sophsiticated if it is possible that a person only has a first or only Last name.

• ###### 2. Re: Calculation for Shortening Middle Name to First Letter

We do have a few only last or first names.  I was able to come up with the below - but am seeing that if I only have a first name it would look like: ", First".  Can you help me fix that?

If ( not IsEmpty ( Contacts::Last ) ; Contacts::Last) & If ( not IsEmpty ( Contacts::First ) ; "," & " " & Contacts::First ) & If ( not IsEmpty ( Contacts::Middle ) ; " " & Left (Contacts::Middle ; 1) & "." )

• ###### 3. Re: Calculation for Shortening Middle Name to First Letter

Last & If ( Not Isempty ( First ; ", " & First ) & If ( Not Isemtpy ( Middle ) ; " " & Left ( MIddle ; 1 ) & "." )

• ###### 4. Re: Calculation for Shortening Middle Name to First Letter

Perfect, thank you.

• ###### 5. Re: Calculation for Shortening Middle Name to First Letter

Spoke too soon, for some reason I'm not able to make this work.  It keep saying it's expecting another variable somewhere.  When I fix what I thought was the missing variable, if there is only a first name it still comes out " , First"

• ###### 6. Re: Calculation for Shortening Middle Name to First Letter

Figured it out. For what it's worth, this is what ended up working for me:

If ( not IsEmpty ( Contacts::Last ) and not IsEmpty ( Contacts::First ) ; Contacts::Last & "," & " " & Contacts::First ) & If ( IsEmpty ( Contacts::First ) ; Contacts::Last ) & If ( IsEmpty ( Contacts::Last ) ; Contacts::First ) & If ( not IsEmpty ( Contacts::Middle ) ; " " & Left ( Contacts::Middle ; 1 ) & ".")