Skip to main content
Answer

Concat Function is creating a space on some records, why?

  • September 14, 2023
  • 8 replies
  • 411 views

Forum|alt.badge.img

Hello,

I am using the following function to combine the account # with the location ID, but somehow the function is creating a space on some of the records, why?

This is the formula I am using, which is working for most of the records, however there are some that contain a space in between.

 

=Concat([BAccount.AcctCD],[Location.LocationCD])

 

Please see attached screenshot. 

 

 

Space between these records

 

Best answer by darylbowman

=Concat(Trim([BAccount.AcctCD]),Replace(Trim([Location.LocationCD]),'MAIN','000')

 

8 replies

palbores
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • September 14, 2023

Hi @jorgep17, you can use the Replace function in GI like this: =Concat(Replace([BAccount.AcctCD],’ ‘,’’) , [Location.LocationCD]).


Keith Richardson
Semi-Pro I
Forum|alt.badge.img+2

They may be fixed width in the database, and such having the space.


You could either Trim, or replace a space with a blank.

 

=Concat(Trim([BAccount.AcctCD]),Trim([Location.LocationCD]))

or 

 

=Replace(Concat([BAccount.AcctCD],[Location.LocationCD]),’ ‘,’’)


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • September 14, 2023

@jorgep17  The reason might be that in the database, these values might be saved with the extra space.

You can use the TRIM() function to remove the space for those texts. like below.

 

=Concat(Trim([BAccount.AcctCD]),[Location.LocationCD])

 

 


Forum|alt.badge.img
  • Author
  • Freshman II
  • September 14, 2023

Great guys,

The =Concat(Trim([BAccount.AcctCD]),Trim([Location.LocationCD])) got rid of the spaces. 

One more thing, how can I use the Replace fuction in this same formula? I need to also replace the text MAIN with 000. See below.

 

Where should I insert the Replace command?

 

=Concat(Trim([BAccount.AcctCD]),Trim([Location.LocationCD]))
=Replace([Location.LocationCD], 'MAIN', '000')

 


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • September 14, 2023
=Concat(Trim([BAccount.AcctCD]),Replace(Trim([Location.LocationCD]),'MAIN','000')

 


Forum|alt.badge.img
  • Author
  • Freshman II
  • September 14, 2023

This one seemed to have done the trick.

Thank you all!!

 

=Concat(trim([BAccount.AcctCD]),Replace([Location.LocationCD], 'MAIN', '000'))


darylbowman
Captain II
Forum|alt.badge.img+15

This one seemed to have done the trick.

=Concat(trim([BAccount.AcctCD]),Replace([Location.LocationCD], 'MAIN', '000'))

This is not going to trim the LocationCD.


Forum|alt.badge.img
  • Author
  • Freshman II
  • September 14, 2023

This one seemed to have done the trick.

=Concat(trim([BAccount.AcctCD]),Replace([Location.LocationCD], 'MAIN', '000'))

This is not going to trim the LocationCD.

 

I see, maybe in my case, it didn’t need to be, as the data showed correctly after without the spaces. So I would assumed the AcctCD was the one needing Trimming. 

Thank you!