Jump to content

Don't leave space if the field is empty


This topic is 2597 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello,

 

Can Someone help me i have a merge code lets say i have 3 fields firstname, middlename and last name and i have a substitute field to put this 3 field

 

Substitute ( Self ;
[ "<<firstname>>" ; table::firstname ] ;
[ "<<middlename>>" ; table::middlename ] ;
[ "<<lastname>>" ; table::lastname ] ; 
)
 
and i put this on this substitute field for example 
 
My name is <<firstname>> <<middlename>> <<lastname>>
 
My problem is if the <<middlename>> is empty it leaves a space is there a way to remove the space without actually removing the <<middlename>> on the center?

 

Link to comment
Share on other sites

Simple answer would be FirstName & “ “ & MiddleName & “ “ & LastName assuming all fields are not empty?

 

Most of the time the data in the fields are not always that clean.

 

This would probably work for you

// Trim removes and leading and trailing spaces. Substitute removes the extra spaces if there is no middle name.
 
Trim(
    Substitute(
        Title & " " & First & " " & Middle & " " & Last;
        [ "  "; " " ];
        // Remove 2 spaces
[ "¶"; "" ]
        // Remove extra carriage returns
    )
)
Link to comment
Share on other sites

I like List() and Substitute().
 
Let( [

first.name = Substitute ( Self  ; "<<firstname>>" ; table::firstname  ) ;

middle.name = Substitute ( Self  ; "<<middlename>>" ; table::middlename  ) ;

last.name = Substitute ( Self  ; "<<lastname>>" ; table::lastname  ) ;

 

result = Substitute ( List ( first.name ; middle.name ; last.name ) ; "¶" ; " " )

];

result

)

 

Link to comment
Share on other sites

This topic is 2597 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

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