Splitting a string column on only first space in ADF

Anonymous
2023-02-10T11:09:59.4233333+00:00

I have a column let us say "FullName" which have below sample data and I want to split the data into 2 derived column fields "FirstName" and "LastName", So I need to split the FullName filed based on only first space we find and need to ignore rest spaces if we have in that field.

The desired output for fields "FirstName" and "LastName" should be as below.

FullName FirstName LastName
AAA AAA Null
AAA BBB AAA BBB
AAA BBB CCC AAA BBB CCC
AAA BBB CCC DDD AAA BBB CCC DDD

Looking forward to getting your help

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,625 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pedro Fiadeiro 216 Reputation points
    2023-02-10T11:43:47.16+00:00

    Hi,

    Assuming you're using a data flow to make those transformations, you can use the following formulas with a derived column

    • FirstName : left(FullName, instr(FullName, ' '))
    • LastName: right(FullName, length(FullName) - instr(FullName, ' '))
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.