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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

[resolved] Need to modify string of numbers and characters from ####CR to -####

Looking for a component or configuration of one to do the task of change numeric value with a CR at the end to be a negative number with the " - " at the beginning of the number. so 32455CR would be converted to -32455. This occurs in several columns, so It would need to be repeatable.
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hello
You can transform it on tMap, eg;
tFileInput--row1--tMap---tLogRow
type in expression of output column as:
row1.columnName.contains("CR")?"-"+row1.columnName.substring(0,row1.columnName.indexOf("CR")):"-"+row1.columnName

Best regards

shong

View solution in original post

4 Replies
Anonymous
Not applicable

Hello
You can transform it on tMap, eg;
tFileInput--row1--tMap---tLogRow
type in expression of output column as:
row1.columnName.contains("CR")?"-"+row1.columnName.substring(0,row1.columnName.indexOf("CR")):"-"+row1.columnName

Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

This works great, I just needed to remove the last "-" and replace it with a " " and then the conversion ran perfectly. Thanks for taking the time to respond to my post.
Anonymous
Not applicable

How about when you want to remove non digit characters and leave numbers only but not remove the . sign for numbers with decimals e.g. 3.5 ml and .6ml . i have used the replace function (\\D) but the thing is it removes the . on these type of numbers so the result is 3 5 and 6 instead of .6 and 3.5
Your help will be much appreciated
Anonymous
Not applicable

Try this in tmap. It will replace all letters and spaces.
row1.a.replaceAll("","").replaceAll(" ","")
Regards,
Rick