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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tmap join and treplace

I have two questions.
1- I connect to sql server and i have a table with two column where if a value is set to null, I join table with second column otherwise I join with first column.
ex. first column - second column
1 X null join with first column
2 XX null join with first column
3 null Y join with second column
4 XXX null join with first column
2- I want substitute the table cell that contain a value in another value but i want substitute entire cell and not only match.
ex. column substitute bye in 1 and all other in 2 ----> column
1 XXbye 1
2 other 2
3 YbyeX 1
4 null 2
Labels (2)
14 Replies
Anonymous
Not applicable
Author

sorry... that become smile in my previous post.
row1.patternCheck.equals("")?2: (row1.patternCheck.toLowerCase().indexOf("bye") >= 0)?1:2)

Thank you for answer but the problem is iterate for each row.
It works only with
ex. row1.patternCheck == "NULL"?1:2 and not row1.patternCheck.equals("NULL")?1:2 or .contains or .indexOf

In these case it works only for first row and then I have a NullPointerException 0683p000009MPcz.png
0683p000009MEGP.png 0683p000009MEKi.png 0683p000009MEUL.png
Anonymous
Not applicable
Author

I solved with routine
ex. public static int refererConverter(String referer) {

if(referer == null)
return 1;
else if (referer.contains("facebook"))
return 2;
else return 3;
}
Anonymous
Not applicable
Author

hi all,

you've got a null pointer exception , so you've to manage null value.
null is NOT a String in Java so =="NULL" or equals ("NULL") could not work !
in ternary expression it could be something like :
referree == null ? 1 :
referer.contains("facebook") ? 2 :
3

I didn't test the code but it should work 0683p000009MA9p.png
Be aware that you sould test if not null before anything else because if it is null, java will try something like
null.contains("facebook") /* source of your null pointer exception : null don't have a 'contains method' */

it could be a better way to put your code in routine than directly in tMap or other component 0683p000009MACn.png
regards
laurent
Anonymous
Not applicable
Author

hi all,

you've got a null pointer exception , so you've to manage null value.
null is NOT a String in Java so =="NULL" or equals ("NULL") could not work !
in ternary expression it could be something like :
referree == null ? 1 :
referer.contains("facebook") ? 2 :
3

I didn't test the code but it should work 0683p000009MA9p.png
Be aware that you sould test if not null before anything else because if it is null, java will try something like
null.contains("facebook") /* source of your null pointer exception : null don't have a 'contains method' */

it could be a better way to put your code in routine than directly in tMap or other component 0683p000009MACn.png
regards
laurent

Thanks Kzone, I have another question:
How can I or join betwen string1 and (string21 or string22)?
ex. id1 string1 id2 string21 string22 result id1 id2
1 bye X null dad 1 W
2 null Y null mam 2 null
3 good W bye null 3 null
4 hello Z null hello 4 Z
My goal is join with string21 but if it is null then join with string22
Anonymous
Not applicable
Author

you cannot make a join on 2 different column in a same tmap or tjoin i think.
So do it in 2 times 0683p000009MACn.png
something like @screenshoot
first join filter null & not null value , then map not null string21 (left outer join) , then read rejected filter row that you have store in hash component and map again on string22.
Depending on String21 , 22 value write result in a single flow.
hope it help
regards
laurent
0683p000009MEIQ.png 0683p000009MEUQ.png