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 in tMap Output that will print the whole value based on a symbol Else leave the value Blank

I am dealing with an Input File that contains a Column with both email addresses and phone numbers. Now I have an email address column in my tMap Output Column. How would I map only the email addresses contained in the input column over and not the phone numbers. I was thinking using @ symbol as the identifier in the values to print the entire value if the value contains an @ sign Else leave the column. 

 

I'm not sure if their is a Contains Function or I could use the wildcards on both sides of the @ sign. So the expression (String Method) would be input.phone&email.equals("*@*")? input.phone&email: ""

 

May need to handle the blanks in the column as well

 

Help would be greatly appreciated and Kudos coming your way!

 

 

Labels (2)
4 Replies
Anonymous
Not applicable
Author

You can use an inline if condition to check for the presence of a '@'.

 

To do this with the following code....

input.phone_email!=null && input.phone_email.indexOf('@')>-1 ? input.phone_email : ""

What the above does is ask first whether the column is NOT null. If it is NOT null it then tests to see if it contains a @ symbol. If it does it returns input.phone_email. Otherwise it returns an empty String. Inline ifs are really useful. The logic before the ? is the test which returns a true or false. The first code after the ? and before the : is the action taken for true, the code after the : is the action taken for false.  

Anonymous
Not applicable
Author

@rhall 

 

Thanks for your solution.

 

If I wanted to have the same logic but with dates or currency instead of email addresses how can that be done within a string method? I have a messy file where I have names and addresses in a Date and Currency field so I need to change all those values to blank and only format the dates and currency, if it actually has a certain date format for instance MM/dd/YYYY.

 

-Andrew

 

 

akumar2301
Specialist II
Specialist II

@sm 

 

can you show it with sample data

 

for date , you can verify with isdate function with specified date format

for currency ,you could download list of all available currencies( ISO 4217) and do a lookup.

https://www.iso.org/iso-4217-currency-codes.html

Anonymous
Not applicable
Author

@sm 

 

    There are lot of pre-built patterns in Profiling perspective of Studio (You need to change Perspective from Integration to Profiling at top right part).

 

   0683p000009M3N1.png

 

You can go through these patterns and either copy these patterns or create analysis report and convert the analysis to integration jobs. 

 

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 🙂