
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tmap and string contains
Hi,
I have a column which contains text string (IDs). There is some logic in our text strings which I would like to use for mapping purposes.
The IDs can be like H123A, H123B or H123C. I am looking to map the data to different columns based on the last character of the text string (A,B or C).
For Example:
If ID is H123A it should go to Column1.
If ID is H123B it should go to Column2.
IF ID is H123C then it should go to Column3.
Can anyone please help me out on this?
Thanks in advance.
Kind Regards,
Arjun
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this it will work as per your requirement
row1.Source.toLowerCase().contains("a") ? row1.Source : "" at column1 on tMap
row1.Source.toLowerCase().contains("b") ? row1.Source : "" at column2 on tMap
row1.Source.toLowerCase().contains("c") ? row1.Source : ""at column3 on tMap
By assuming we only get either a or b or c not a and b or b and c both at a time in a string.
at the end of function i written string with no spaces.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @arjunvigneshwar
am assuming you have 3 columns in the output side in tMap
row1.Source.toLowerCase().contains("ID") ? "H123A" : row1.Source at column1 on tMap
row1.Source.toLowerCase().contains("ID") ? "H123B" : row1.Source at column2 on tMap
row1.Source.toLowerCase().contains("ID") ? "H123C" : row1.Source at column3 on tMap
Please write in all three columns, i just written lower case to avoid some case, some id may not be in Caps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Manish,
Will the below commands work when ever the fields contains the string "A" "B" or "C".
If the string contains the alphabet A it should go t Column 1, if B then to Column2 or else to column 3.
Thanks in advance.
Kind Regards,
Arjun Rathinam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Francois,
It is not necessary that the A or B or C should be the 5 character of the string. It can be anywhere. Basically if the string contains the Aplhabet A it should be in column1 or if it contains B anywhere then it should be in Column2 or else it should be in Column3.
But when I tried your solution I am getting the attached error.
Thanks in advance.
Kind Regards,
Arjun
Error.PNG

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@arjunvigneshwar did you tried the function i mentioned earlier?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@ksingh Yes, I did. I am getting the attached output.
In am currently getting the output which highlighted in yellow. But I am expecting the output to be like the one highlighted in green.
PFA,..
Kind Regards,
Arjun
Output.PNG

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try this it will work as per your requirement
row1.Source.toLowerCase().contains("a") ? row1.Source : "" at column1 on tMap
row1.Source.toLowerCase().contains("b") ? row1.Source : "" at column2 on tMap
row1.Source.toLowerCase().contains("c") ? row1.Source : ""at column3 on tMap
By assuming we only get either a or b or c not a and b or b and c both at a time in a string.
at the end of function i written string with no spaces.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this works perfect!
Thanks a lot.
Kind Regards,
Arjun

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@arjunvigneshwar okay thanks, thanks for sharing the example screenshot, so i figured it out easily
