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: 
Edith1
Creator
Creator

tMap replace character if column is not null

The data is writing out like this ["PII"].

I want to remove the [""] and convert it to PII.

In tMap, I have this expression:

(row14.LABELS!=null && row14.LABELS="" && StringHandling.TRIM(row14.LABELS).length() > 0)?row14.LABELS.replaceAll("[", "")

When I run the job, I am getting the hard error of Detail Message: aggregated_row_tAggregateRow_1 cannot be resolved to a variable.

What am I doing wrong in the above expression? Can I please have an example of how to replace those characters I don't want with blanks if there's data. This column data can be null.

Labels (2)
1 Solution

Accepted Solutions
evansdar
Contributor II
Contributor II

Youll have to escape all double quotes and brackets. The following worked for me:

row14.LABELS != null ? row14.LABELS.replaceAll("[\\[\\]\"]","") : null

 

You are probably getting that error because you're using an assignment operator '=' when you should be using an equality operator '==' in your conditional. (fyi use '==' for object comparisons and .equals() method for string comparison) If all you need to check is for nulls, my conditional should be sufficient.

View solution in original post

2 Replies
evansdar
Contributor II
Contributor II

Youll have to escape all double quotes and brackets. The following worked for me:

row14.LABELS != null ? row14.LABELS.replaceAll("[\\[\\]\"]","") : null

 

You are probably getting that error because you're using an assignment operator '=' when you should be using an equality operator '==' in your conditional. (fyi use '==' for object comparisons and .equals() method for string comparison) If all you need to check is for nulls, my conditional should be sufficient.

Edith1
Creator
Creator
Author

Thank you so much for your help 😀. This worked. I also appreciate the explanation on when to use == or .equal. I am new to all this.