How do I conditionally concatenate strings in Calc using 'if'?

i want to merge the value of 3 cells into a new cell.

  • D = title
  • E = first name
  • F = second name

=E2 & " " & F2 works fine and merge the name together
but not every row has an title so i´m looking for a script like:

=(IF(D2 is not empty print the value incl. a space behind)) & E2 & " " & F2

maybe anyone can help me?

One solution:

=IF(ISBLANK(D1),E1&" "&F1,D1&" "&E1&" "&F1)

If the text-value in D1 is already the result of an expression testing with ISBLANK() will not work. In this case you have to test for “not the empty string”. The formula may look then as follows:

=IF(D1="";"";D1&" “)&E1&” "&F1

Thank you!
It works great!

@rogerr could you please accept the answer so others know your question was answered?