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: 
zalibra
Contributor III
Contributor III

Parse values inside parenthesis with tMap

I have a combination of values in my "input_data" field which I need to put in two separate fields. Below are the possible values in "input_data":

1. US Dollar (USD)

2. JEP

3. Zimbabwean Dollar (2009) (ZWL)

 

I would want my output to be:

    output_1                                     output_2

1. US Dollar                                    USD

2. JEP                                             

3. Zimbabwean Dollar (2009)        ZWL

 

For output_1, I used:

row1.input_data.substring(0,row1.input_data.indexOf("("))

and for output_2, I used:

row1.input_data.substring(row1.input_data.indexOf("(")+1,row1.input_data.indexOf(")")) 

but it gave an error for JEP since there was no parenthesis and for the other two, the output was:

 

    output_1                                     output_2

1. US Dollar                                    USD

3. Zimbabwean Dollar                   2009

 

Whenever there are two parentheses, I always want to take the second value for output_2. Does anyone know what the commands for output_1 and output_2 should be?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi
For output1:
row1.c1.contains("(")?row1.c1.substring(0,row1.c1.lastIndexOf("(")):row1.c1

for output2:
row1.c1.contains("(")?row1.c1.substring(row1.c1.lastIndexOf("(")+1,row1.c1.length()-1):""

Please try and let me know if it works.

Regards
Shong

View solution in original post

2 Replies
Anonymous
Not applicable

Hi
For output1:
row1.c1.contains("(")?row1.c1.substring(0,row1.c1.lastIndexOf("(")):row1.c1

for output2:
row1.c1.contains("(")?row1.c1.substring(row1.c1.lastIndexOf("(")+1,row1.c1.length()-1):""

Please try and let me know if it works.

Regards
Shong
zalibra
Contributor III
Contributor III
Author

Worked! Thanks.