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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

String Method syntax in tMap Expression for Two seperate columns have to be populated for a seperate column to have a True or False Value

I have two input columns one is Organization and the other is Name.

 

I have a separate output column with the field Type. If Organization is populated then the Name field is not going to be populated and the other way around. So I need String Method that will populate a column with either "OR" if Organization Input Field is populated or "IN" if Name field is populated.

 

(IS NOT NULL).equalsIgnoreCase(row1.Name) && (IS NOT NULL).equalsIgnoreCase(row1.Organziation) ? "OR" : "IN"

 Not sure if there is a IS NOT NULL function in JAVA. I would need to handle NULLS in this syntax as well

 

Please advise

 

Andrew

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi @sm 

 

Empty string is different from null in Java. So why don't you check some of the old Talend posts which has handled this scenario.

 

For example, the below one. You need to do an OR clause for empty string at same level as NULL.

 

https://community.talend.com/t5/Design-and-Development/resolved-How-to-check-values-if-they-are-quot...

 

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

5 Replies
vapukov
Master II
Master II

Hi,

 

equals compare strings values

like name = "IS NOT NULL"

 

in case where you need check NULL it could be like:

row1.Name!=null && row1.Organziation!=null ? "OR" : "IN"

or

row1.Name==null || row1.Organziation==null ? "IN" : "OR"
Anonymous
Not applicable
Author

Hi Andrew,

 

    A slight Modification I could think is as below.

 

   If both input values are null, output wll be null in this case.

 

Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name)
                        ? null
                        :(!Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name)
                              ?"OR":"IN")

If you don't want to check above condition, you can take second part of the logic assuming only one of them will be populated at a time.

 

!Relational.ISNULL(row1.Organziation) && Relational.ISNULL(row1.Name) ?"OR":"IN"

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 🙂

Anonymous
Not applicable
Author

Hey @nthampi 

 

I'm getting "IN" value for all values in my output column. With trying both of your String Methods

 

I even tested it with a tFixedFlowInput and tLogRow and still got the same Output. So if the Organization Input column is populated then the First Name field will be blank and not NULL. This may change the syntax around. It's the same the other way around if First Name is populated then the Organization Input Column will be Blank and not NULL. 

See SS below

 

0683p000009M3Vj.png0683p000009M3Vo.png0683p000009M3TB.png

Anonymous
Not applicable
Author

Hi @sm 

 

Empty string is different from null in Java. So why don't you check some of the old Talend posts which has handled this scenario.

 

For example, the below one. You need to do an OR clause for empty string at same level as NULL.

 

https://community.talend.com/t5/Design-and-Development/resolved-How-to-check-values-if-they-are-quot...

 

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 🙂

Anonymous
Not applicable
Author

@sm 

 

Hi Andrew,

 

     I hope you were able to resolve the issue from the above details. Could you please mark the topic as resolved since you have all the necessary details for your original query of the post? It will help other Talend members during their reference.

 

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 🙂