Topic: Concat ???

Hi, is there a way to use the Concat procedure in a calculated field?  What I wanna do is to have in one raw the Lastname and the name.
The script that I use in the calculated filed is the following

Select Concat (Lastname, ' ' ,name ) as fullname
From employee

2 (edited by derek 2021-10-10 17:30:24)

Re: Concat ???

Hi,
Have a look at the attachment.  There are two slightly different ways of doing it
1.  calculated field 'cffullnamea' is a bit longer but more correct
2.  calculated field 'cffullnameb' is shorter but leaves a leading space if there is no first name but there is a last name (see screenshot in the attachment) which would affect any sort sequence.
If there is always a first name AND a last name, then it is simply first_name||' '||last_name;  however, if either first name or last name is 'null', then nothing will appear if you don't check for 'null'
Regards,
Derek.

Post's attachments

Attachment icon concatenate calculatedfield pozidis.zip 384.87 kb, 178 downloads since 2021-10-10 

Re: Concat ???

Heya,
.
I know this doesn't apply to you for this case in your project, but I was solving a similar combination of names just recently.  I wanted to share what I came up with for a semi-logical concatenation snippet:
.

ifnull(nullif(employee.nameLast || ', ' || employee.nameFirst || ' (' || employee.nameNick || ')', employee.nameLast || ', ' || employee.nameFirst), employee.nameLast || ', ' || employee.nameFirst)

.
I needed an if this else that type of logic in a calculated field.  As far as I know, there is no such structure for calculated fields.  I was about to ask for help with it, but then I experimented with the ifnull and nullif combinations and got it working as desired.
.
Anyways, maybe it will help someone else in the future.

"Energy and persistence conquer all things."

4 (edited by v_pozidis 2021-10-11 07:43:47)

Re: Concat ???

I am wondering if we can just create from your example a calculated field that connect the fname and the lname in one field. I don't care if there is an empty field.
I don't undwrstand the ifnull and the nullif functions

Thank's for helping me

Re: Concat ???

Yeah I didn't mean to complicate your question, so probably best to disregard my post.
.
I started out with two name fields in a project I was working on.  Then I needed to add an optional name and so this was how I handled it.  There is probably an even better way to do it, but I wanted to share what I came up with for that.  You know... in case you might add a 3rd name sometime.  lol

"Energy and persistence conquer all things."