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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator III
Creator III

Script table with condition

i have a table with two language_id

id   ab_id   subject_line            language_id

1      1       test_mail_english           1

2      1        test_mail_spanish          2

3      2        test_mail_english_1       1

4      2                                               2

5      3                                               1

6      4                                               1

7     4      test_mail_spanish_3         2



so my output should be


id   ab_id   subject_line            language_id

1      1       test_mail_english           1

3      2        test_mail_english_1       1

5      3                                               1

7     4      test_mail_spanish_3         2


here i want to write a script to get subject_lines, where it first checks for subject_line with language_id = 1, if not empty get subjectline,if it is empty, then only it has to get spanish subject_line i.e  with language_id = 2. How could i do this?

4 Replies
Anonymous
Not applicable

Maybe this

IF(language_id='1', subject_line, IF(language_id='2' AND TRIM(subject_line)='', 'spanish')         AS subject_line

MK9885
Master II
Master II

IF(language_id='1' AND TRIM(subject_line)='', 'spanish', IF(language_id='1', subject_line)AS subject_line

sumanta12
Creator II
Creator II

TAB1:

load

id,

IF(LEN(subject_line)=0 AND language_id=1,'SPANISH_SUBJECT_LINE',subject_line) AS subject_line,

IF(LEN(subject_line)=0 AND language_id=1,2,language_id) AS language_id;

TAB2:

load * inline [

id,subject_line,language_id

1,test_mail_english,1

2,test_mail_spanish,2

3,test_mail_english_1,1

4,,2

5,,1

6,test_mail_spanish_2,1

7,test_mail_spanish_3,2

];

berryandcherry6
Creator III
Creator III
Author

Hi all,

Can you look into updated query. I think i was not clear in my question. i have written expected output.