Name Split

Hi everyone


This is the column I am using, it contains a name of a person and surname, so in order for me to extract the name and surname I use ‘split’
image
image

This is for surname:
image

But then the surname split will not work if on the column ‘Customer Name’ there is only a name and no surname…it sends an error, anyone how I should solve for this?, if there is no surname do i maybe need an IF statement?

Hi @Anelisa_Bolosha1

Use the below expression in assign activity to store the surname,

- Assign -> Surname = If(Not(String.isnullorempty(Customername.Trim.Split(" "c)(1))), Customername.Trim.Split(" "c)(1).to string, " ")

By using the above expression if there is no surname in the cell then it will store a blank value in surname variable. So it won’t throw any error.

Hope it helps!!

@Anelisa_Bolosha1

You can try this in surname field

If(customerName.Trim.Split(" "c).Count>1, customerName.Trim.Split(" "c)(1),String.Empty)

Alternately if you want to use same name for surname as well then simply use

CustomerName.Trim.Split(" "c).Last - this returns name as surname if no surname else it would return the surnamr

Cheers

Hi @mkankatala , Thank you for response back… I was just trying it out, took the expression you gave, I got the below error

@Anil_G , thanks so much. The first condition did the trick.

Much appreciated…
Cheers :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.