Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to remove the character in the concatenation if the 2nd value of the concatenation is blank

I'm Concatenating Zip Codes. The input fields separate the 5 digit zip with 4 digit extension. So my concatenation String method for my output column that is a full zip code is row2.ZIP+ '-' +row2.PLUS4 . I need to modify this to remove the '-' mark if the PLUS4 field is empty. I have some output values returning #####-. I would want it to just return #####.

 

Please Advise

 

Thanks,

 

Andrew

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

@sm 

 

Hi Andrew,

 

      Lets try slightly different method.

 

Relational.ISNULL(row2.PLUS4) || row2.PLUS4.trim().equals("") 
                                 ? row2.ZIP
                                 : row2.ZIP+"-"+row2.PLUS4

    I hope this will help you.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

View solution in original post

7 Replies
akumar2301
Specialist II
Specialist II

row2.ZIP+ (row2.PLUS4 == null || row2.PLUS4.trim.length() == 0) : "" : "-" + row2.PLUS4)

Anonymous
Not applicable
Author

@uganesh 

 

Thanks for the reply.

 

I'm getting a syntax error with your string method. See Problem Tab SS below

 

row2.ZIP+ (row2.PLUS4 == null || row2.PLUS4.trim.length() == 0) : "" : "-" + row2.PLUS4)

 

0683p000009M3Pb.png

akumar2301
Specialist II
Specialist II

row2.ZIP+ (row2.PLUS4 == null || row2.PLUS4.trim().length() == 0) : "" :
"-" + row2.PLUS4)
Anonymous
Not applicable
Author

@uganesh 

 

Still getting some syntax errors and conversions errors when using that String Method.

 

Both of my Input columns are both Strings

 

row2.ZIP+ (row2.PLUS4 == null || row2.PLUS4.trim().length() == 0) : "" :
"-" + row2.PLUS4)

 

0683p000009M3Kw.png

 

akumar2301
Specialist II
Specialist II

row2.ZIP+ (row2.PLUS4 == null || row2.PLUS4.trim().length() == 0) ? "" :
"-" + row2.PLUS4
Anonymous
Not applicable
Author

Hi Andrew,

 

You can use below logic in your expression 

(row3.lname.equals(null)||row3.lname.isEmpty())?row3.fname:row3.fname+"_"+row3.lname

 

Thanks,

Dhanraj

Anonymous
Not applicable
Author

@sm 

 

Hi Andrew,

 

      Lets try slightly different method.

 

Relational.ISNULL(row2.PLUS4) || row2.PLUS4.trim().equals("") 
                                 ? row2.ZIP
                                 : row2.ZIP+"-"+row2.PLUS4

    I hope this will help you.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂