cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

SharePoint Calculated Column Combine First Middle Last Name Without Additional Spaces

I'm creating a flow that will generate new personnel folders using document sets in SharePoint. I can populate the individual name fields (First, Middle, Last, Suffix); however, I want to have columns that will contain the first and last name or full name. Since people can also create personnel folders manually, I wanted the full name columns to be calculated. So when creating a folder they only have to enter the First, Middle Last, Suffix and then the full name columns will automatically populate.

 

I'm having an issue formatting the SharePoint calculated column and want to make sure it is correct before I set this as a content type and use it on all the folders.

I found plenty of examples which were merging only the first and last name exactly like the Microsoft Support Examples of Common Formulas ; but I could not find any examples where the middle name was included accounting for if someone doesn’t have a middle name.

 

If the person has a first and last name without the middle and the formula [FIRST_NAME]&” “&[MIDDLE_NAME]&” “&[LAST_NAME] would result in double spaces in between the first and last name.

I also need to account for input error where a space is included before or after the name, or a space is the only value in the field. For example when the name is entered into the fields, instead of putting a middle name or leaving blank they type a space. This would cause the field to not be blank and if using the standard merge calculation there would now be 3 spaces between first and last name.

 

I went through trial and error to find the formula that would work on a test sharepoint. My end result is a long formula checking for ISBlank while trimming any additional spaces and adding a space between names. The only way I could finally get it to work is by wrapping the entire formula in a TRIM() so that any additional spaces added by the merge would be removed.

 

Basically it checks if the field is blank, if so then add a space " ", if not then add the FieldName with a space in front, ex. " "&TRIM(FieldName).

 

My final formula:

TRIM(TRIM([FIRST_NAME])&IF(ISBLANK(TRIM([MIDDLE_NAME]))," "," "&TRIM([MIDDLE_NAME]))&IF(ISBLANK(TRIM([LAST_NAME]))," "," "&TRIM([LAST_NAME]))&IF(ISBLANK(TRIM([NAME_SUFF]))," "," "&TRIM([NAME_SUFF])))
  • The first trim will wrap the entire name formula TRIM(
  • TRIM([FIRST_NAME])&
  • IF(ISBLANK(TRIM([MIDDLE_NAME]))," "," "&TRIM([MIDDLE_NAME]))&
  • IF(ISBLANK(TRIM([LAST_NAME]))," "," "&TRIM([LAST_NAME]))&
  • IF(ISBLANK(TRIM([NAME_SUFF]))," "," "&TRIM([NAME_SUFF]))
  • ) Closing initial trim

Below is a screenshot of each type of test names, the character lengths, result of ISBLANK, and result of ISNULL.

Example Names Lengths and BlanksExample Names Lengths and Blanks

Below are the names from the example. I'm using an underscore _ to represent spaces " " in field names. Blanks are when there is no value entered in the field.

  1. Willow Sarah Eastwood PHD
  2. Willow Eastwood PHD
  3. Willow Eastwood
  4. Blank Space Middle Name: Willow _ Eastwood PHD
  5. Blank Space in Middle and Suffix: Willow _ Eastwood _
  6. Blank Spaces in All Names: _ _ _ _
  7. All Names Not Filled Left Blank: blank blank blank blank
  8. First Name Only: Willow blank blank blank
  9. Last Name Only: blank blank Eastwood blank
  10. Trailing spaces on names: Willow_ Sarah_ Eastwood_ PHD_

Is there an easier way than a long validation formula? Is there a reason I can't find more examples of this issue? Are there name inputs that would cause errors or #Value from the formula?

1 ACCEPTED SOLUTION

Accepted Solutions

I also posted this on SharePoint Tech Community  and got a response for a solution from another user @kalpeshvaghela  that works just as well. I think his is a little easier to read than the one I have so I will mark it as a solution.

 

My solution formula:

=TRIM(TRIM([FIRST_NAME])&IF(ISBLANK(TRIM([MIDDLE_NAME]))," "," "&TRIM([MIDDLE_NAME]))&IF(ISBLANK(TRIM([LAST_NAME]))," "," "&TRIM([LAST_NAME]))&IF(ISBLANK(TRIM([NAME_SUFF]))," "," "&TRIM([NAME_SUFF])))

 

Easier to read solution formula:

=CONCATENATE(TRIM(FIRST_NAME),IF(ISBLANK(TRIM(MIDDLE_NAME)),""," "),TRIM(MIDDLE_NAME),IF(ISBLANK(TRIM(LAST_NAME)),""," "),TRIM(LAST_NAME),IF(ISBLANK(TRIM(NAME_SUFF)),""," "),TRIM(NAME_SUFF))

 

These formulas are basically the same, but using Concatenate helps clean it up to be easier to understand at first look.

View solution in original post

9 REPLIES 9

For reference here is the initial test which I just used the basic Text&" "&Text formula as used in the microsoft examples and other general name combine examples I found. It basically adds additional spaces and only works if every name field is filled in correctly.

I had to test different formulas so I added columns the SP List and replaced the test formulas each time. The sharepoint column CombineFormula is where the results of the name joins. I used the column "Double Space in Combine Formula" to check for any additional spaces between words within the final CombineFormula. I also added columns to check the length and see if it was blank. 

 

=[FIRST_NAME]&" "&[MIDDLE_NAME]&" "&[LAST_NAME]&" "&[NAME_SUFF]

 

These are the results in SharePoint and Excel. You can see the additional spaces better in the excel names.

 

Name Examples Initial Basic Formula ResultsName Examples Initial Basic Formula Results

Here is the results after making the final formula calculated column CombineFormula. I was using the column "Double Space in Combine Formula" to see if there were any additional spaces between words or within the final CombineFormula. It also checked the length and if it was blank. I don't understand why the zero 0 length final don't count as ISBLANK.

 

=TRIM(TRIM([FIRST_NAME])&IF(ISBLANK(TRIM([MIDDLE_NAME]))," "," "&TRIM([MIDDLE_NAME]))&IF(ISBLANK(TRIM([LAST_NAME]))," "," "&TRIM([LAST_NAME]))&IF(ISBLANK(TRIM([NAME_SUFF]))," "," "&TRIM([NAME_SUFF])))

 

CombineFormula Final Name ResultsCombineFormula Final Name Results

 

I also posted this on SharePoint Tech Community  and got a response for a solution from another user @kalpeshvaghela  that works just as well. I think his is a little easier to read than the one I have so I will mark it as a solution.

 

My solution formula:

=TRIM(TRIM([FIRST_NAME])&IF(ISBLANK(TRIM([MIDDLE_NAME]))," "," "&TRIM([MIDDLE_NAME]))&IF(ISBLANK(TRIM([LAST_NAME]))," "," "&TRIM([LAST_NAME]))&IF(ISBLANK(TRIM([NAME_SUFF]))," "," "&TRIM([NAME_SUFF])))

 

Easier to read solution formula:

=CONCATENATE(TRIM(FIRST_NAME),IF(ISBLANK(TRIM(MIDDLE_NAME)),""," "),TRIM(MIDDLE_NAME),IF(ISBLANK(TRIM(LAST_NAME)),""," "),TRIM(LAST_NAME),IF(ISBLANK(TRIM(NAME_SUFF)),""," "),TRIM(NAME_SUFF))

 

These formulas are basically the same, but using Concatenate helps clean it up to be easier to understand at first look.

Hello,

 

Thank you for this solution. I am attempting to make a calculated column in excel to combine multiple address entries into one column. I deal with military bases, so in the MS Form, I have branched around housing areas on the bases depending on the base that they choose. It's nice and customer friendly for a customer to select a base and then see the housing areas only for that base that they chose rather than all of them, but it has left a lot of blanks in my SharePoint List due to branching in the form. I would like to consolidate the address into one column, and I have applied the formulas you listed, but I cannot seem to get it to work. I keep getting a Syntax error not supported message when I finish. I've tried both solutions now and I keep getting the same. I hope this posts ok, it's my first time posting here. Below is what I put in the calculation field though:

 

=CONCATENATE(TRIM(Base),IF(ISBLANK(TRIM(Courtney Housing)),""," "),TRIM(Courtney Housing),IF(ISBLANK(TRIM(Foster Housing)),""," "),TRIM(Foster Housing),IF(ISBLANK(TRIM(Kadena Housing)),""," "),TRIM(Kadena Housing),IF(ISBLANK(TRIM(Lester Housing)),""," ")TRIM(Lester Housing),IF(ISBLANK(TRIM(McT Housing)),""," "),TRIM(McT Housing),IF(ISBLANK(TRIM(Shields Housing)),""," "),TRIM(Shields Housing),IF(ISBLANK(TRIM(Kinser Housing)),""," "),TRIM(Kinser Housing))

 

=TRIM(TRIM([Base])&IF(ISBLANK(TRIM([Courtney Housing])),""," "),TRIM([Courtney Housing])&IF(ISBLANK(TRIM([Foster Housing])),""," "),TRIM([Foster Housing])&IF(ISBLANK(TRIM([Kadena Housing])),""," "),TRIM([Kadena Housing])&IF(ISBLANK(TRIM([Lester Housing])),""," ")TRIM([Lester Housing])&IF(ISBLANK(TRIM([McT Housing])),""," "),TRIM([McT Housing])&IF(ISBLANK(TRIM([Shields Housing])),""," "),TRIM([Shields Housing])&IF(ISBLANK(TRIM([Kinser Housing])),""," "),TRIM([Kinser Housing]))

 

Any chance of an assist in finding the error? I have tried both formulas with and without square brackets around the other column titles as well.

 

Respectfully,

Nate_willy

The first thing I would check is the column internal names. It can be different than what is shown on the display name. There has also been a change in how SharePoint deals with spaces in column names. So you need to go check and see what it shows for your column internal name and use that in the formula.

 

I'm guessing that if you created the column named "Courtney Housing", the sharepoint internal column name is "CourtneyHousing" without a space in the middle. It used to replace spaces with _x0020_ and the internal column name would be "Courtney_x0020_Housing". 

 

In my example below I created a new column called "My - New_Column Name". The sharepoint internal column name can be seen in the address bar as "My_x002d_New_ColumnName". This is because it removed the spaces and encoded the special character dash "-" as _x002d_ in the name. 

 

Note: If I was to rename this column to say "My Favorite Column", the internal column name does not change and would still be addressed as "My_x002d_New_ColumnName". The internal column name doesn't change if you rename the column. That is considered changing the display name.

 

So go to your column settings and look at the internal column name for each of your columns, and then use that in your formula and see if it makes a difference.

 

SharePoint Column NameSharePoint Column Name

Follow up question for you @Nate_willy about the data from the MS Form to SharePoint. If the SharePoint list is just a collector of responses and you don't expect any changes to the data, you could do all of this formatting in Power Automate.

 

It is essentially the same output, except you don't have to deal with a calculated column in SharePoint. You do a similar concatenate and trim formula in a Power Automate expression and it puts the whole thing as text into a SharePoint column.

 

If the form responses go to SharePoint list and there are changes/edits/updates to the data, I can see how a calculated column could be helpful. But if it will be static text with no changes, I'd do all of the formatting in power automate so that you are controlling all of the data output at a single place (the power automate flow).

 

Up to you, the results will be the same. (However lists have a limit to character count within a calculation formula, limit on nested if statements in a formula, as will as a limit of 48 calculated columns per list. So using power automate instead of a calculated column can be more effective in different situations.)

@wskinnermctc,

 

Thank you so much for these responses. I have definitely considered utilizing Power Automate to consolidate the address fields, but not all of the information in the SharePoint List is static. I work in Student Transportation and what I’m working on here is a registration process that gets us out of the dark ages of having parents come in to the office to fill out paper forms or sending a hand typed email to our org box. With this process, we’ve controlled a lot of the data input through drop downs, radio buttons, and a ton of branching instead of open text entries. So when we receive the info in our list, my staff will be assigning their names to it and marking Info Verified in a choice column I created. When they do that, Power Automate runs a flow to send them a nice little customer friendly email letting them know we’ve received it, checked it, and the transportation specialist assigned to their request is (name). Then they’ll take the address and figure out where the closest bus stop is to their home and assign them to it, also in the list and also with another flow running to notify them of the details.

 

Sorry to give you the whole process. Just wanted to give you all that so you can see it’s not the address columns that are updated. Those are indeed static. But can I still use power automate to run a flow to combine the columns if other columns change? I’m thinking an if(empty… expression maybe?

 

oh, maybe I can restrict it by view though in the advanced options of a flow. Thoughts?

 

Thanks again!

Nate_willy

Try to get the calculated column working first by using the column name check example above.

 

It might be better to have the calculated column in this situation because multiple people are using the SP List and might need to correct or edit some address information. They only have to correct the individual box, and the full address will be corrected.

 

You can at least get the setup running with the calculated column, and then make any changes later if you want.

For example, that format name column from my initial post still exists in the sharepoint list, but I don't use it anymore.

 

(I personally don't use the View options in flow because it seems to be a problem later if you change the view name, add columns, or other changes. I'd rather deal with all of the data and columns in the flow without a view filter, so I know any view changes won't break my flow.) 

@wskinnermctc,

 

So I ended up going a totally different direction with this info anyway and no longer require the Concat formula/expression or any others for that matter.

 

Thank you for all of the assistance though, and I hope you have a good one!

 

Nate_willy

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,297)